Skip to content

Instantly share code, notes, and snippets.

@Myrrel
Created March 15, 2024 13:43
Show Gist options
  • Save Myrrel/0d7118c5b0f5a2655a8cf47378590286 to your computer and use it in GitHub Desktop.
Save Myrrel/0d7118c5b0f5a2655a8cf47378590286 to your computer and use it in GitHub Desktop.
SceneDelegate-SwiftUI
import UIKit
import SwiftUI
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use a UIHostingController as window root view controller
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()
}
}
func sceneDidDisconnect(_ scene: UIScene) {}
func sceneDidBecomeActive(_ scene: UIScene) {}
func sceneWillResignActive(_ scene: UIScene) {}
func sceneWillEnterForeground(_ scene: UIScene) {}
func sceneDidEnterBackground(_ scene: UIScene) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment