uiview上的动画

纳西尔

我已经以编程方式创建了一个UIView。现在我想在动画上显示视图。我的代码如下。请注意该代码是在按钮单击事件。

 view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 284)];
view1.backgroundColor = [UIColor redColor];
[self.view addSubview: view1];
UIButton *cancel = [UIButton buttonWithType:UIButtonTypeRoundedRect];
cancel.frame = CGRectMake(265, 0, 55, 20);
[cancel setTitle: @"Cancel" forState: UIControlStateNormal];
[cancel addTarget:self action:@selector(cancelView:) forControlEvents:UIControlEventTouchUpInside];
奇拉格·皮帕里亚(Chirag Pipaliya)

试试吧....

 [UIView beginAnimations: nil context: nil];
 [UIView setAnimationBeginsFromCurrentState: YES];
 [UIView setAnimationDuration: 0.5];
 view1.frame = CGRectMake(20,45,110,548); //Set frame according your choice
 [UIView commitAnimations];

希望我能帮上忙。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章