视图未覆盖全屏(编程故事板 Swift)

Kir*_*llC 4 xcode interface-builder storyboard ios

在 Xcode 11 中,初始窗口现在在 SceneDelegate 中配置,这里是我的代码和图片上的结果:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

     print("Scene willConnectTo.")
       guard let windowScene = (scene as? UIWindowScene) else { return }

    //  window =  UIWindow(frame: windowScene.coordinateSpace.bounds)
    window =  self.window ?? UIWindow()
     let mainView = ViewController()
    mainView.title = "TEST"
     let navigationController = UINavigationController()
    navigationController.viewControllers = [mainView]
    window?.backgroundColor = .red 
    window?.windowScene = windowScene
    window?.rootViewController = navigationController
    window?.makeKeyAndVisible()
}
Run Code Online (Sandbox Code Playgroud)

谁能建议如何使视图覆盖所有屏幕?

在此输入图像描述

小智 5

确保您有 LaunchScreen 故事板。