1

I have a navigation based application and I want to change the animation of the push and pop animations. How would I do that?

When i push any viewController it represent as pop and When i pop any viewController it represent as push.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Ketan Patel
  • 550
  • 4
  • 11
  • 1
    As of iOS 7, there is official API for this; see UINavigationControllerDelegate's custom transition animation support. There's also a WWDC 2013 Video about this. From here you'll have to look into if it supports ios8 ect. – Darcey Mckelvey May 09 '15 at 13:59
  • have a look at this question http://stackoverflow.com/questions/1406037/custom-animation-for-pushing-a-uiviewcontroller – EagerMike May 09 '15 at 14:11

2 Answers2

2
   CATransition *transition = [CATransition animation];
    transition.duration = 0.3f;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
        transition.subtype=kCATransitionFromRight;
    kCATransitionFromLeft   or  kCATransitionFromRight
    [self.navigationController.view.layer addAnimation:transition forKey:nil];

add this before you push the view controller for custom animation

Akshay Karanth
  • 347
  • 1
  • 13
1
-(void)pushViewController:(UIViewController *)viewController{

    float width = self.frame.size.width;
    float height = self.frame.size.height;

    [viewController.view setFrame:CGRectMake(width, 0.0, width, height)];
    [self addSubview:viewController.view];   
    [UIView animateWithDuration:0.33f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
                     animations:^{
                         [viewController.view setFrame:self.frame];
                         [self setFrame:CGRectMake(0.0, 0.0, width, height)];
                     }
                     completion:^(BOOL finished){

                     }];

}
Ruchish Shah
  • 319
  • 1
  • 6