I've noticed when setting the preferredColorScheme
in my SwiftUI app the .alert
and .confirmationDialog
modifiers don't use the colorScheme
. Also the launch screen doesn't use the colorScheme
either. It seems to be using system defaults, is this normal behaviour?
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.preferredColorScheme(.light)
}
}
}
I was also unable to get better results using UIKit
's overrideUserInterfaceStyle
. The launch screen is still using system defaults, unsure how to solve that in SwiftUI
without a launch screen. Also the code becomes pretty ugly and much more extensive.
guard let scene = scenes.first as? UIWindowScene else { return }
scene.keyWindow?.overrideUserInterfaceStyle = .light // .light .dark .unspecified