这是iOS 13的一个改变。用户将开始期望能够轻松地滑动关闭模态窗口,因此值得考虑支持该功能。
如果您确实想使用旧的呈现样式,可以在呈现之前设置所呈现的视图控制器的modalPresentationStyle属性来实现。
vc.modalPresentationStyle = .fullScreen
或在视图控制器本身中进行覆盖:
override var modalPresentationStyle: UIModalPresentationStyle {
get { .fullScreen }
set { assertionFailure("Shouldnt change that ") }
}
或在故事板中设置segue:
.modalPresentationStyle = .fullScreen
,但是那样不起作用。有效的方法是在呈现VC实例之前以编程方式设置.modalPresentationStyle
。 - xta override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the presented navigationController and the view controller it contains
let navigationController = segue.destination
navigationController.modalPresentationStyle = .fullScreen
}