iPhone - 动画视图控制器演示文稿 [英] iPhone - animating a view controller presentation

查看:96
本文介绍了iPhone - 动画视图控制器演示文稿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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 framework add 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 - 动画视图控制器演示文稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆