SwiftUI — Color.yellow renders as brown on iOS device (but yellow in simulator)

786 Views Asked by At

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:

Screenshot

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)
        }
    }
}
1

There are 1 best solutions below

1
Brent On BEST ANSWER

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.