I am using this extension to export RGB components of a Color value which is changed when the user selects a color from the new ColorPicker view for SwiftUI 2:
I'm observing the value change for my color state like this:
@State private var textColor = Color.white
ColorPicker("Text Color", selection: $textColor, supportsOpacity: false)
.onChange(of: textColor) { newColor in
print(newColor.components)
}
But, for some colors in the picker, when the value is printed, it has some negative values in it. What can cause this problem?
(red: 0.9607847332954407, green: 0.9254906177520752, blue: -9.62614990385191e-07, opacity: 1.0)