xcode 如何更改 UINavigationController 推送过渡样式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28023528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:30:29  来源:igfitidea点击:

How do I change the UINavigationController push transition style?

iosxcodeuiviewcontrolleruinavigationcontroller

提问by Kex

I am using a navigation controller and push segues to control the flow of my app. Is there anyway to change the default animation of right-to-left for the push segues? Is there something I can overwrite somewhere?

我正在使用导航控制器并推送 segue 来控制我的应用程序的流程。反正有没有改变push segues从右到左的默认动画?有什么我可以覆盖的地方吗?

Thanks

谢谢

回答by Mahesh

I did the following and it works fine.. and is simple and easy to understand..

我做了以下操作,效果很好..而且简单易懂..

CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
//transition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[[self navigationController] popViewControllerAnimated:NO];

And the same thing for push..

和推同样的事情..

don't forget to include QuartCore (#import )

不要忘记包含 QuartCore (#import )

回答by Kirit Modi

Yes , you can changes transition style of ViewController with different animation. see below link.

是的,您可以使用不同的动画更改 ViewController 的过渡样式。见下面的链接。

  1. transition style animation

  2. ViewController transition

  3. Custom ViewController transition

  4. ADTransitionController

  5. transition

  6. ViewController T

  1. 过渡风格动画

  2. 视图控制器过渡

  3. 自定义 ViewController 过渡

  4. AD转换控制器

  5. 过渡

  6. 视图控制器

回答by Karan Singla

You can create an NSObjectclass and subclass it from UIStoryboardSegueand then override the -(void)performfunction to give it your own custom animations. There you can use any animations either pre-defined or your own. For details, checkout this link.

您可以创建一个NSObject类并将其子类化UIStoryboardSegue,然后覆盖该-(void)perform函数以为其提供您自己的自定义动画。在那里您可以使用任何预定义的或您自己的动画。有关详细信息,请查看此链接