Contents

stringRepresentation

Returns a formatted string with the unpremultiplied color and alpha components of the color.

Declaration

var stringRepresentation: String { get }

Discussion

The string representation always has four components: red, green, blue, and alpha.

Some example string representations of colors:

CIColor

stringRepresentation

[CIColor colorWithRed:0.2 green:0.4 blue:0.6]

"0.2 0.4 0.6 1.0"

/CIColor/yellowColor

"1.0 1.0 0.0 1.0"

To create a CIColor instance from a string representation, use the init(string:) method.

If the CIColor was initialized with a CGColor in a non-RGB CGColorSpace then it will be converted to sRGB to get the red, green, and blue components.

This property is not KVO-safe because it returns a new NSString instance each time. The value of the NSString will be the same each time it is called.

See Also

Getting Color Components