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

Tom*_*yer 1 ios presentviewcontroller swift

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

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

此UIViewController以全屏大小显示

mat*_*att 5

您需要为呈现的视图控制器提供一个自定义transitioningDelegate,然后可以将自定义UIPresentationController插入到演示过程中,frameOfPresentedViewInContainerView您将对其进行适当的重写.

  • 答案与我告诉你的答案完全相同_并告诉你如何做. (3认同)