【问题标题】:Animating the transition of a subview in Cocoa Touch在 Cocoa Touch 中动画子视图的过渡
【发布时间】:2011-10-25 15:18:24
【问题描述】:
我有一个包含子视图的视图。子视图将包含其他视图。
当用户点击左侧菜单时,子视图的内容会发生切换:当前视图会被移除,新视图会被添加。
我想用类似于 UIModalTransitionStyleFlipHorizontal 的效果对此进行动画处理。考虑到它不会是模态表单(它不会覆盖整个屏幕),我该怎么做?
【问题讨论】:
标签:
objective-c
cocoa-touch
animation
core-animation
uimodaltransitionstyle
【解决方案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;