When I run the following Swift 3.0.1 line on iOS 10.2.1:
let color = CIColor(color: UIColor(hue: 0.72, saturation: 1.00, brightness: 0.78, alpha: 1));
I get the following error:
'*** -CIColor not defined for the UIColor UIExtendedGrayColorSpace 1 1; need to first convert colorspace.'
According to the documentation:
The color object. The color information represented by this object is in an RGB colorspace. On applications linked for iOS 10 or later, the color is specified in an extended range sRGB color space. On earlier versions of iOS, the color is specified in a device RGB colorspace.
Source: https://developer.apple.com/reference/uikit/uicolor/1621931-init
What is the appropriate syntax to get the CIColor
from this UIColor
now that the CIColor
is in the device RGB colorspace and the UIColor
is in the extended sRGB colorspace?
Based on the feedback provided in the comments, I found the source of the error:
Later in the method, I called .ciColor on an instance of UIColor. This fails because the UIColor instance was not first created by CIColor.
It appears as though the following conditions hold: