动画Cocoa Touch中子视图的转换

时间:2011-10-25 15:18:25

标签: objective-c cocoa-touch animation core-animation uimodaltransitionstyle

我有一个带有子视图的视图。子视图将包含其他视图。

enter image description here

当用户点击左侧的菜单时,将切换子视图的内容:将删除当前视图并添加新视图。

我想用类似于UIModalTransitionStyleFlipHorizo​​ntal的效果来设置动画。我怎么能这样做,考虑到它不是一个模态形式(它不会覆盖整个屏幕)?

1 个答案:

答案 0 :(得分:1)

self.currentView.userInteractionEnabled = NO;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.currentView cache:YES];
[self.currentView removeFromSuperview];
[self.view addSubview:self.someOtherView];
[UIView commitAnimations];

self.view.userInteractionEnabled = YES;
self.currentView = self.someOtherView;