没有圆角的模态?

der*_*ida 3 uiviewcontroller ios swift

我想在没有圆角的iOS中创建一个Modal - Modal代表UINavigationController中的UIViewController.

生病时尝试:

override func viewWillAppear(animated: Bool) {
    self.navigationController?.view.layer.cornerRadius = 0
}
Run Code Online (Sandbox Code Playgroud)

它不起作用.有解决方案吗?

编辑:我的意思是这里的圆角:

在此输入图像描述

该代码只是一个例子(这里删除了所有其他无用的代码)

der*_*ida 6

已经找到了解决方案.将一个类分配给RootViewController并添加到那里:

override func viewWillLayoutSubviews() {
   super.viewWillLayoutSubviews()
   view.superview?.layer.cornerRadius  = 0.0
}
Run Code Online (Sandbox Code Playgroud)

工作良好.

  • 将`superview.layer.cornerRadius`设置为0是关键部分。我不需要设置`mastToBounds = false` (2认同)