我有一个视图控制器,我想将其作为弹出窗口呈现。我该如何改变它的大小?
let carsViewController = CarsViewController()
carsViewController.modalPresentationStyle = .Popover
if let popoverPresentationController = a carsViewController.popoverPresentationController {
popoverPresentationController.permittedArrowDirections = .Up
popoverPresentationController.sourceView = carsButton
presentViewController(alertsViewController, animated: true, completion: nil)
}
答案 0 :(得分:2)
花了我一些时间,但我终于找到了答案。它就像初始化视图控制器后添加以下行一样简单。
carsViewController.preferredContentSize = CGSize(width: 220,height:90)