如何自定义Modal View Controller呈现动画? [英] How to custom Modal View Controller presenting animation?
本文介绍了如何自定义Modal View Controller呈现动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想添加一个CAAnimation(或其他东西),而不是设置uiviewcontroller的modalTransitionStyle
.这段代码可以在navigationController中执行自定义动画
Instead of setting uiviewcontroller's modalTransitionStyle
, I want to add an CAAnimation(or some other thing). This code can perform an custom animation in navigationController
CATransition* transition = [CATransition animation];
transition.duration = 0.4;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:adjustViewController animated:NO];
如何将其实现到Modal View Controller?
How can I implement it to a Modal View Controller?
推荐答案
您只需要将过渡添加到窗口的层,并提供您的控制器即可,而不是推送它:
You just need to add the transition to the window's layer, and present your controller rather than pushing it:
CATransition* transition = [CATransition animation];
transition.duration = 1;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
[self.view.window.layer addAnimation:transition forKey:kCATransition];
[self presentViewController:adjustViewController animated:NO completion:nil];
这篇关于如何自定义Modal View Controller呈现动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文