Created
June 25, 2021 16:08
-
-
Save pietrorea/8fc2c83a26322f3909ab630aee2f5414 to your computer and use it in GitHub Desktop.
Set initial view controller in code using SceneDelegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First, delete the two storyboard entries in the Info.plist (one newer one for SceneDelegate and a newer one for AppDelegate) | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
guard let windowScene = scene as? UIWindowScene else { | |
return | |
} | |
let blueViewController = UIViewController() | |
blueViewController.view.backgroundColor = .blue | |
let window = UIWindow(windowScene: windowScene) | |
window.rootViewController = blueViewController | |
self.window = window | |
window.makeKeyAndVisible() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment