'What is the best practice when using .ultraThinMaterial on dark mode using SwiftUI?
The iOS app I am making supports dark mode, and I am using .ultraThinMaterial in the background of my navigation bar for better contrast and visibility. While it looks amazing in light mode, the dark mode version seems to have this white hue to it which looks, in my opinion, kind of cheesy.
I'm looking for a solution that I could implement for dark mode only, to avoid it looking like this:
The pictures don't do it justice for how bad it looks on a physical iPhone Screen, at least on my monitor
Here is the code that uses the .ultraThinMaterial:
Color.clear
.background(.ultraThinMaterial)
.blur(radius: 20)
.saturation(0.0)
.ignoresSafeArea()
.frame(height:70+80)
.offset(y: 50)
Thanks!
Solution 1:[1]
You could do something like this
struct ContentView: View {
@Environment(\.colorScheme) var colorScheme
var body: some View {
ZStack{
if colorScheme == .light{
Color.clear
.background(.ultraThinMaterial)
.blur(radius: 20)
.saturation(0.0)
.ignoresSafeArea()
.frame(height:70+80)
.offset(y: 50)
}
}//: ZSTACK
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


