有没有办法改变模态视图控制器外观的动画样式? [英] Is there a way to change the animation style of a modal view controller appearance?
问题描述
我使用了以下两行代码:
self.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:viewcontroller animated:YES];
使视图控制器的视图从屏幕底部动画,效果很好。 p>
我的问题是:我可以改变这个动画的风格,使视图不总是从屏幕的底部滑动吗?例如
modalTransitionStyle
视图控制器上的属性设置视图控制器将如何显示,而不是它将用于呈现不同控制器的动画。所以你可以这样做:
viewcontroller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:viewcontroller animated:YES];
(我习惯于让视图控制器指定自己的模式过渡样式initWithCoder :,但这是一个样式问题,我猜)。
可用的转换风格列表是在此处。所以,尝试动画,一个控制器翻转像一张扑克牌,好像另一个打印在对面:
viewcontroller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewcontroller animated:YES];
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 always 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];
这篇关于有没有办法改变模态视图控制器外观的动画样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!