Yes, I have looked for an answer already. None of the solutions work, except one that doesn\'t give the option for a fade transition, only flip or curl.
Like this:
Joris Kluivers's answer in Swift 3 :
CATransaction.begin()
CATransaction.setDisableActions(true)
let animation = CATransition()
animation.type = kCATransitionFade
self.navigationController?.view.layer.add(animation, forKey: "someAnimation")
_ = self.navigationController?.popViewController(animated: false)
CATransaction.commit()
For this type of transition I would really recommend a modal view controller, thats the way the system was designed.
But if you insist on using the navigation controller there is a way, though somewhat ugly.
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
CATransition *transition = [CATransition animation];
[transition setType:kCATransitionFade];
[self.navigationController.view.layer addAnimation:transition forKey:@"someAnimation"];
[self.navigationController popViewControllerAnimated:YES];
[CATransaction commit];
The CATransaction
will disable all standard animations. The CATransition
adds a fade transition to the navigation controller layer when views are swapped (in this case removing the viewcontroller view that is popped).
In iOS 7 above, you may want to look into UIViewControllerAnimatedTransitioning
for presented view controllers, or UINavigationControllerDelegate
method :
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
I have some sample code from another question for more info.