iPhone: How to do a presentModalViewController animation from left to right

hol picture hol · Dec 27, 2010 · Viewed 16.7k times · Source

I am presenting a model view with animation. As a default it comes from bottom to top. How can I make the animation to go from left to right? I know I could use a navigation controller. But actually the presenting view does not need a navigation bar and also the modally presented view does not need a navigation bar. Still I want a transition from left to right.

Answer

Manju picture Manju · Nov 20, 2013

You can animate from right to left while presenting a view controller by using the following code

CATransition *transition = [CATransition animation];
            transition.duration = 0.4;
            transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            transition.type = kCATransitionPush;
            transition.subtype = kCATransitionFromRight;
            [self.view.window.layer addAnimation:transition forKey:nil];
            [self presentViewController:localitiesView animated:NO completion:nil];