【发布时间】:2011-12-22 14:59:43
【问题描述】:
我有一个包含两个视图(redView、blueView)的视图控制器。视图小于主视图。
我想通过动画从 redView 更改为 blueView。如果使用这个没有动画发生。
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight
forView:redView cache:YES]; // !!! I WILL CHANGE THIS
[self.view addSubview:blueView];
[redView removeFromSuperview];
[UIView commitAnimations];
如果我将代码更改为这个,那么动画就可以了,但整个 mainView 都会动画,这是我不希望发生的事情。我只想翻转子视图。我应该注意到 2 个子视图处于相同的位置。 (框架)有什么想法吗?
[UIView beginAnimations:@"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight
forView:self.view cache:YES];
[self.view addSubview:blueView];
[redView removeFromSuperview];
[UIView commitAnimations];
【问题讨论】:
标签: iphone cocoa-touch animation uiview subview