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

时间:2019-11-16 16:23:32

标签: ios xcode storyboard interface-builder

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

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()
}

有人可以建议如何使视图覆盖所有屏幕吗?

enter image description here

2 个答案:

答案 0 :(得分:2)

确保您具有LaunchScreen故事板。

答案 1 :(得分:0)

似乎无法以编程方式执行LaunchScreen,因为屏幕将在应用程序启动之前由操作系统加载,请参见here