代码之家  ›  专栏  ›  技术社区  ›  Anand Rockzz

ViewController-全屏

  •  0
  • Anand Rockzz  · 技术社区  · 5 年前

    第二个ViewController的顶部有这个空间,它几乎在手机上显示为一个可关闭的弹出窗口。如何制作全屏(删除橙色箭头所指的空格)?

    enter image description here

    0 回复  |  直到 5 年前
        1
  •  13
  •   Casper Zandbergen    5 年前

    这是iOS 13的变化。用户将开始期待能够刷走情态动词,因此可能值得研究支持它。

    如果您真的打算使用旧的演示样式,可以在演示之前设置演示视图控制器的modalPresentationStyle:

    vc.modalPresentationStyle = .fullScreen
    

    或者在视图控制器本身中覆盖它:

    override var modalPresentationStyle: UIModalPresentationStyle {
        get { .fullScreen }
        set { assertionFailure("Shouldnt change that 😠") }
    }
    

    或者在情节提要中设置:

    storyboard segue example

        2
  •  0
  •   Sandeep Ramji    5 年前

    遇到了同样的问题。覆盖UIViewController实现中的“准备就绪”序列。设置navigationController。modalPresentationStyle to。全屏

        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
    }