I want to change the "slide from right to left" transition of my navigation view controller when it pushes another view controller. I found an option in the storyboard but it doesn't seem to work. The transition style is still the same. By clicking the destination view controller in the storyboard I found this, although it looks like the transitions are for the modal style segue :
So, my question is, is it possible to make the push style segue transition to look differently ? And if so, how ?
You can use CATransition within a custom Segue to achieve any kind of transition. Here is sample code.
-(void)perform {
__block UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
__block UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.duration = .25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[sourceViewController.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
}
You visit this link for more details http://blog.jambura.com/2012/07/05/custom-segue-animation-left-to-right-using-catransition/
In order to have the push transition you need to be using a UINavigationController connecting your views. Those are all modal transition options for one off transitions.
By the same token, at least in storyboards you can't use anything other than push if your are already using a UINavigationController.
The easiest way I've found to get around this limitation is to do it in code and to wrap a push without animation wrapped in a UIView Animation or CAAnimation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With