Learn Courses My Dashboard

ColorPicker SwiftUI

The color for the ColorPicker("", selection: $color) was initialize as color = Color(red: 1, green: 0, blue: 0) yet the RGB sliders of the ColorPicker show 233/51/35.
I expected 255/0/0
How can I fix this ?

That’s a result of SwiftUI using the standard RGB color space. If you use the extended sRGB color space and provide values outside the 0-1 range, you will see what you are expecting.

@State private var color = Color(.sRGBLinear, red: 2, green: -1, blue: -1)