Is it possible in SwiftUI to force a View
to use light or dark mode — like overrideUserInterfaceStyle
in UIKit does?
.colorScheme()
is deprecated does not work with the background well.
.preferredColorScheme()
is the way now. Does the job with the background too.
TestView1()
.preferredColorScheme(.dark)
TestView2()
.preferredColorScheme(.light)
Developer docs for .preferredColorScheme()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With