Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 452
hol Avatar asked Dec 27 '10 19:12

hol


People also ask

What is presentViewController?

The presentViewController:animated:completion: method always displays the view controller modally. The view controller that calls this method might not ultimately handle the presentation but the presentation is always modal. This method adapts the presentation style for horizontally compact environments.


1 Answers

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];
like image 111
Manju Avatar answered Sep 25 '22 18:09

Manju