Swift - iOS 9:如何在 iOS 9 中显示自定义大小的 UIViewController?

Swift - iOS 9: How do i present UIViewController with custom size in iOS 9?

我有一个视图,我想显示一个自定义大小的 UIViewController。但是我没有成功。这是我的代码。

var vx = KeyboardViewController()
vx.modalPresentationStyle = UIModalPresentationStyle.FormSheet
vx.preferredContentSize = CGSizeMake(self.view.frame.width, 150)    
self.presentViewController(vx, animated: true, completion: nil)

这个UIViewController是全屏显示的

您需要为呈现的视图控制器提供自定义 transitioningDelegate,然后它将能够将自定义 UIPresentationController 插入呈现过程,您将适当地覆盖其 frameOfPresentedViewInContainerView