Skip to content

Instantly share code, notes, and snippets.

@KiranJasvanee
Last active December 26, 2019 06:31
Show Gist options
  • Save KiranJasvanee/4f88c8dd1efb3cb5e1b08b900e9f9636 to your computer and use it in GitHub Desktop.
Save KiranJasvanee/4f88c8dd1efb3cb5e1b08b900e9f9636 to your computer and use it in GitHub Desktop.
GettingStartedwith-SwiftUI-2
// Create the SwiftUI view that provides the window contents.
let contentView = ContentView()
// Use a UIHostingController as window root view controller.
if let windowScene = scene as? UIWindowScene {
// cast UIScene instance to UIWindowScene to assign that scene to UIWindow.
let window = UIWindow(windowScene: windowScene)
// Use UIHostingController to create a view controller for SwiftUI view contentView.
window.rootViewController = UIHostingController(rootView: contentView)
// assign UIWindow instance to your delegate's window object to make it display when app launch happens.
self.window = window
// at the end, make it visible.
window.makeKeyAndVisible()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment