简体   繁体   English

使用Swift在UIViewController上部分显示UIViewController

[英]Show UIViewController partially over a UIViewController with Swift

I would like to show a UIViewController over a UIViewController from the top of the screen (for example, when a button is pressed) and I would like it to be shown only of a part of the screen (for example 50%). 我想从屏幕顶部(例如,当按下按钮时)在UIViewController上显示UIViewController,并且我希望仅在屏幕的一部分(例如50%)中显示它。

Can it be done? 能做到吗

One view controller can present another view controller modally. 一个视图控制器可以模态呈现另一个视图控制器。 The visual style of the presentation can be one of the predefined ones from UIKit, or you can set 演示文稿的视觉样式可以是UIKit中预定义的样式之一,也可以设置

presentingViewController.modalPresentationStyle = .Custom 

and then implement the custom animated transitioning which is not a trivial task so its best if you find a step by step guide or watch a WWDC video for that. 然后实施自定义动画过渡,这并不是一件容易的事,因此,如果您能找到分步指南或观看WWDC视频,那将是最好的选择。 In the custom implemented transitioning class, it is you who controls the position of the presented view that belongs to the presentedViewController. 在自定义实现的过渡类中,由您控制属于presentedViewController的呈现视图的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM