我已经以编程方式创建了一个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];
试试吧....
[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] 删除。
我来说两句