Has anyone experienced this problem? It looks like a bug in Apple\'s code and I will submit a radar if people agree that this code should do what I think it should do. I\'m
What you're not grasping is that nothing about CGColorGetComponents makes any claims or guarantees about how many components there are or what they mean. That information is contained in the color's color space. If you look at the color space of white and black, you will see they are both forms of grey:
let sp = CGColorGetColorSpace(UIColor.whiteColor().CGColor)
println(sp) // kCGColorSpaceDeviceGrey
Thus, they are expressed in just two values: the amount of grey, and the alpha.
Hence, white is [1.0,1.0]
- which, if you ignore the extra two numbers which you should not have been reading in the first place, is exactly what you got.
Similarly, black is [0.0,1.0]
, which is also what you got.