Advertisement

Customize the UINavigationController pop transition

Here’s the problem: wanted to have crossfade on all transitions to/from a particular view controller.

self.vc = [[ViewController alloc] init];

[self.vc setDelegate:self];
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 pushViewController:self.vc animated:NO];