Search code examples
iphonecocoa-touchcore-graphicsuicolorcgcolor

What does CGColorGetComponents() return?


CGFloat* colors = CGColorGetComponents(hsbaColor.CGColor);

Does this return a float, or an array of floats? It looks like the asterisk is shorthand for creating an array. Is that correct?

When I call this function on the CGColor property of an HSB UIColor object does it convert the values to RGB?


Solution

  • Yes, it returns an array of CGFloats. Specifically, it returns "an array of intensity values for the color components (including alpha) associated with the specified color."

    The color components returned depend on what color space the passed CGColorRef uses.

    More information can be found in the CGColor documentation.