'SwiftUI — Color.yellow renders as brown on iOS device (but yellow in simulator)
Why does Color.yellow appear brown on my iPhone X but yellow in my simulator? It's not a display problem, as this iPhone X screenshot of a test app shows:
As you can see, Color(red: 1.0, green: 1.0, blue: 0.0)
(the lower-right square) appears yellow but Color.yellow
(the circle) appears brown. Here's the code that generated the screenshot:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
ForEach(0...4, id: \.self) { green in
HStack {
ForEach(0...4, id: \.self) { red in
Color(red: Double(red)/4.0, green: Double(green)/4.0, blue: 0.0)
}
}
}
Circle().foregroundColor(.yellow)
}
}
}
Solution 1:[1]
Do you have the increase contrast accessibility setting enabled on your iOS device?
I found that it causes the system yellow color to be displayed as brown in some circumstances.
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 | Brent |