如何从屏幕顶部而不是底部呈现 UIViewController?
我正在使用 UIViewController 并使用 PresentModalViewController:controllerr 动画:YES 来呈现它,但我想如果它从屏幕顶部向下滑动而不是从底部向上滑动,有什么方法可以做到这一点?
I am using a UIViewController and I use presentModalViewController:controllerr animated:YES to present it but I would like if it would slide down from the top of the screen instead of up from the bottom, any way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我创建了一个用于从所有 4 个方向推送 ViewControllers 的函数:
头文件包含以下内容:
I created a function for pushing the
ViewControllers
from all 4 directions:The header file contains the following:
我使用以下代码从顶部对视图控制器进行动画处理。
它将
modalViewController
的UIView
添加到mainViewController
,为其添加动画,然后从mainViewController
中删除UIView
。 code>mainViewController 和presentsViewController:
没有动画。I use the following code to animate a viewController in from the top.
It adds the
UIView
of themodalViewController
to themainViewController
, animates it in, then removes theUIView
from themainViewController
andpresentsViewController:
without animation.您所描述的不是内置的过渡样式;而是内置的过渡样式。请参阅此处查看 Apple 提供的列表。如果您绝对需要视图控制器以这种方式显示,则必须自己为其设置动画。
What you're describing isn't a built-in transition style; see here for a list of those that Apple provides. If you absolutely need your view controller to appear this way, you'll have to animate it yourself.
您必须
#import
QuartzCore
框架并添加过渡动画,然后更改:animated:YES
到:
动画:否
。You have to
#import
theQuartzCore
framework and add the transition animation, then change:animated:YES
to:
animated:NO
.