How do I change the UINavigationController push transition style?

10,165

Solution 1

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 )

Solution 2

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

  1. transition style animation

  2. ViewController transition

  3. Custom ViewController transition

  4. ADTransitionController

  5. transition

  6. ViewController T

Share:
10,165
Kex
Author by

Kex

Swift. Objective C. Python.

Updated on June 15, 2022

Comments

  • Kex
    Kex almost 2 years

    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?

    Thanks

  • Kex
    Kex over 9 years
    where do I put this code? does it work with the interface builder i.e. performSegue ?
  • Kex
    Kex over 9 years
    I used this, it works nicely. Is there anyway to change the background color from black? It kind of flashes black when it transitions.
  • Boris Gafurov
    Boris Gafurov almost 8 years
    this works, only one draw back is that status/nav bar flickers.
  • Legatro
    Legatro about 7 years
    This is a duplicate answer: stackoverflow.com/questions/2215672/…