1

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)
        }
    }
}
Anton
  • 2,512
  • 2
  • 20
  • 36
  • I just copy/pasted your code and ran it on the preview canvas/ a simulator and on my real iPhone device. All three showed exactly the same output (allowing for screen brightness differences). In my tests the circle is not brown, it a yellow colour. It is not the same as the rectangular yellow patch but it isn't brown. Do you know the colour quantities that make up the predefined `.yellow` colour? All of the predefined `color` have been mixed/chosen for how they look in different situations, not for colour purity. – Magnas Jun 23 '20 at 14:49
  • Thanks, @Magnas. I can't find it documented anywhere what the RGB values are for `Color.yellow` — though I'm guessing if I input those directly it would work fine, given that the color squares look fine. And the circle does look fine for me everywhere else, including the simulator and my physical iPad. Also: Color.orange looks strange on my iPhone X too, though the other color presets look fine. – Anton Jun 23 '20 at 22:38

1 Answers1

2

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.

Brent
  • 71
  • 3
  • Thank you, Brent!!!! That is indeed the issue. No idea how increase contrast was set to on, but that made all the difference. I had given up on this. What a nice surprise!! – Anton May 12 '22 at 18:46