Search code examples
iosuitableviewuistoryboardsegue

Cusom UIStoryboardSegue back animation not work as expected


For some reason I want to have a custom push animation for my segue transition in storyboard which instead of pushing from right to left it pushes from left to right, I developed a custom segue which does this with this code:

UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
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];

The problem is when back button in next view is clicked the segue animation is default one and it has not been changed (it should be right to left but instead it shows left to right which is default one)

How should I change back animation too?


Solution

  • actually it's my fault,UIStoryboardSegue has no control on back animation because it belongs to uiviewcontroller pop animation ! and for purpose of mine i should have write custom pop animation for my scene.