开发者

Is there a way to change the animation style of a modal view controller appearance?

I am trying to animate the appearance and disappearance of two view controllers' view.

I used the following two lines of code:

self.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:viewcontroller animated:YES]; 

to make the view controller's view animate in from the bottom of the screen, which works well.

My question is: can I change the style of this animation so that the view isn't alw开发者_开发知识库ays sliding in from the bottom of the screen? How can I make it animate in from the top of the screen, for example?


The modalTransitionStyle property on a view controller sets how that view controller will appear, not the animation that it will use to present a different controller. So you'd do something like:

viewcontroller.modalTransitionStyle=UIModalTransitionStyleCoverVertical; 
[self presentModalViewController:viewcontroller animated:YES];

(and I'm in the habit of having view controllers dictate their own modal transition style in an overridden initWithCoder:, but that's a style question I guess).

The list of available transition styles is here. So, to try the animation where one controller flips over like a playing card, as if the other were printed on the opposite side:

viewcontroller.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal; 
[self presentModalViewController:viewcontroller animated:YES];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜