uiview上的动画

时间:2013-07-24 11:26:38

标签: ios animation 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];

2 个答案:

答案 0 :(得分:1)

试试吧......

 [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];

希望我帮助过。

答案 1 :(得分:0)

将此用于带动画的显示视图

https://github.com/kohtenko/KOPopupView