Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chourobin/3177758 to your computer and use it in GitHub Desktop.
Save chourobin/3177758 to your computer and use it in GitHub Desktop.
UINavigationController custom pop/push transition animation
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@interface UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController;
- (void)fadePopViewController;
@end
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@implementation UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController
{
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.view.layer addAnimation:transition forKey:nil];
[self pushViewController:viewController animated:NO];
}
- (void)fadePopViewController
{
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.view.layer addAnimation:transition forKey:nil];
[self popViewControllerAnimated:NO];
}
@end
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@interface UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController;
- (void)fadePopViewController;
@end
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@implementation UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController
{
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.view.layer addAnimation:transition forKey:nil];
[self pushViewController:viewController animated:NO];
}
- (void)fadePopViewController
{
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.view.layer addAnimation:transition forKey:nil];
[self popViewControllerAnimated:NO];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment