6

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
  • 8,023
  • 9
  • 56
  • 129
  • you can use this tutorial, http://www.objc.io/issue-12/custom-container-view-controller-transitions.html I am used this to my app: http://www.appdesignvault.com/custom-transition-ios-7/ – ErasmoOliveira Jan 19 '15 at 11:29
  • is it not possible to do a transition such as flip horizontal that can be selected in the interface builder? – Kex Jan 19 '15 at 11:42

3 Answers3

11

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 )

harinsa
  • 3,176
  • 5
  • 33
  • 53
Mahesh
  • 204
  • 1
  • 6
  • 1
    where do I put this code? does it work with the interface builder i.e. performSegue ? – Kex Jan 19 '15 at 14:05
  • I used this, it works nicely. Is there anyway to change the background color from black? It kind of flashes black when it transitions. – Kex Jan 19 '15 at 16:11
  • this works, only one draw back is that status/nav bar flickers. – Boris Gafurov May 02 '16 at 16:45
  • 2
    This is a duplicate answer: http://stackoverflow.com/questions/2215672/how-to-change-the-push-and-pop-animations-in-a-navigation-based-app – Legatro Feb 26 '17 at 13:40
1

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

Kirit Modi
  • 23,155
  • 15
  • 89
  • 112
0

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