首页 > 解决方案 > View on View 控制器在 Xcode 11 上都是方形的,怎么样?

问题描述

视图控制器上的视图是方形的

我试图手动(通过拖动)更改它的大小,但仍然无法正常工作。

标签: swiftxcodeviewautolayoutstoryboard

解决方案


如果您的视图以编程方式呈现(而不是通过 storyBoard),请记住这一点:从 XCode 11 及更高版本开始,当您为 iPad 构建时,您必须添加“modalPresentationStyle = .fullScreen”以获得全屏视图,而不是方形视图。如下:

let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen 
self.present(vc, animated: true, completion: nil)

如果你想在新的viewController上透明,你可以写“.overFullScreen”,如下:

let vc = UIViewController()
vc.modalPresentationStyle = .overFullScreen 
self.present(vc, animated: true, completion: nil)

推荐阅读