My SwiftUI app uses a SceneDelegate with an extended UIHostingController to change the status bar style.
class MyHostingController<Content: View>: UIHostingController<Content> {
@objc override dynamic open var preferredStatusBarStyle: UIStatusBarStyle {
StyleManager.shared.statusBarStyle
}
}
I noticed that in iOS 16 beta 7, the status bar style is not applied when the hosted view contains a TabView or a NavigationView with .navigationBarHidden(true).
Is this an iOS 16 bug? Or is there any way to change the status bar style manually?
struct ContentView1: View {
var body: some View {
TabView(selection: .constant(0)) {
Text("Status bar style cannot be applied.")
}
}
}
struct ContentView2: View {
var body: some View {
NavigationView {
Text("Status bar style cannot be applied.")
.navigationTitle("title")
.navigationBarHidden(true) // if false, status bar style can be applied.
}
}
}