I’m experimenting with a “pure” SwiftUI app. It doesn’t have a SceneDelegate
so I’m unsure of where to put Hosting Controller stuff that I need for when it’ll be running on iOS.
Previously in the SceneDelegate
I’d have code that would say something like:
let contentView = ContentView()
window.rootViewController = UIHostingController(rootView: contentView)
Now I just have an @main
file with:
var body: some Scene {
WindowGroup {
ContentView()
}
}
So where does the Hosting Controller stuff go (or how else can I access UIKit features that SwiftUI doesn’t have? (Specifically, I want to mess with the status bar, auto hiding the home indicator, and a few things about light/dark mode that SwiftUI’s preferredColorScheme
doesn’t cover.)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…