我有一个视图控制器,它在其视图的给定区域显示 2 个子视图控制器的视图。2 个子视图控制器是 FlopVC 和 FipVC。
我想为从一个子视图到另一个子视图的过渡设置动画。我正在使用的代码是:
-(IBAction)flip:(id)sender{
UIViewController *newVC = nil;
if (self.isFlip) {
newVC = [[FlopVC alloc] initWithNibName:nil bundle:nil];
}else{
newVC = [[FipVC alloc] initWithNibName:nil bundle:nil];
}
newVC.view.frame = CGRectMake(120, 20, 240, 260);
[self.view addSubview:newVC.view];
[UIView transitionFromView:self.currentVC.view
toView:newVC.view
duration:0.9
options:UIViewAnimationTransitionFlipFromLeft
completion:^(BOOL finished) {
self.currentVC = newVC;
self.isFlip = ! self.isFlip;
}];
}
子视图被交换,但没有任何动画。我究竟做错了什么?
PS 完整的项目在这里。