问题描述
我有一个UINavigationControl,我想提供一个视图控制器从顶部推出它并从视图中将其移除到顶部。
I have a UINavigationControl and I would like to present a view controller pushing it from the top and removing it from the view pushing it to the top.
是否有一种更改调用时使用的默认动画的方法
Is there a way to change the default animation used when you call
[self.navigationController pushViewController:myViewController animated:YES];
到另一个动画而不是从右向左推动或我是否必须自己设置动画?
to another animation instead of pushing right to left or do I have to animate it myself?
在第二种情况下,我该怎么做?
In the second case, how do I do that?
谢谢。
推荐答案
导入Quartzcore框架
在.h文件中添加标题行
Import Quartzcore frameworkadd header line in .h file
#import <QuartzCore/QuartzCore.h>
比你需要调用下一个viewController,只需添加这个动画行
than where you need to call next viewController, just add this animation line
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setDuration:0.2f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[self.view layer] addAnimation:animation forKey:@"pushIn"];
这是调用视图控制器并添加超级视图,当你回到这个视图时,只需添加相同的动画只保留左右,而不是设置removeFromSuperView ..
Here is call to view controller and add in super view, when you BACK TO this view, just add same animation maintain only left and right, than set removeFromSuperView..
classObj = [[ClassController alloc] initWithNibName:@"Xib Name" bundle:[NSBundle mainBundle]];
[self.view addSubview:classObj.view];
这篇关于iPhone - 动画视图控制器演示文稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!