I am NOT using navigation controller, and I am using storyboards.
I have to make a transition from 1 view controller to other, for which I am using segue.
Now I set the segue style to Custom, and in the corresponding class, I override the perform
method.
-(void)perform
{
UIViewController *sourceViewController = [self sourceViewController];
UIViewController *destinationViewController = [self destinationViewController];
CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[sourceViewController.view.layer addAnimation:transition forKey:kCATransition];animated:NO];
[sourceViewController presentViewController:destinationViewController animated:YES completion:nil];
}
But there is also a property of the destination view controller modalTransitionStyle
.
So Right now, the source VC goes from left to right as if it is being pushed, but I want to show that it is being pushed by the destination view controller. Instead, the destination VC does a 'Cover Vertical' by default, and there are only four options available for the modalTransitionStyle
property, none of which is working for me.
I think to make it work, this animation should be added to some superview layer, a superview from which both view controllers have been presented. But there is no such superview..
All of the ViewControllers in my app inherit from
MyViewController
which, in addition to some other default behaviours, has this property:And this code:
Then, in the ViewControllers where I want to slide-in, I have:
Calling a new ViewController is just like normal:
Usually you would give a storyboardId to the destinationController and call it like this from the sourceViewController:
Optionally, you can do it manually like this:
** EDIT **
Inverse function (similar to the back button in the navigation controller):