I have a UILabel with black color;
i am writing the following code to get black color’s components.
UIColor *aColor = [aLabel.textColor retain];
const CGFloat* components = CGColorGetComponents(aColor.CGColor);
CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();
but always this is giving Green color components instead of black color components;
Is any one have idea about this?
Am i passing different color space?
🙁 Please help me.
Most likely wrong colorspace. I guess the alpha component of the grayscale colorspace gets where you think the green component should be.
I use this function to create a string from UIColor, I only encounter RGB and Grayscale colorspaces, so I just interpret every color with less than 4 (R+G+B+A) components as grayscale.
of course this method is not save for all cases, you should adopt it to your requirements.