CGFloat* colors = CGColorGetComponents([UIColor redColor].CGColor);
Google了一下,找到一个方法,记录备忘。自己亲身试过可行!
1 2 3 4 5 6 7 8 9 10 11 12 13 | CGFloat R, G, B; |
方法三:
在stackoverflow找到的,未试过,应该没什么问题
|
The only way I know of for doing this is to create a Core Graphics bitmap context in an RGB color space and draw into it with your color. You can then read out the RGB values from the resulting bitmap. Note that this won't work for certain colors, like pattern colors (eg. [UIColor groupTableViewBackground
You can use it something like this:
|
本文介绍三种从UIColor中提取RGB值的方法,适用于不同的颜色空间,并提供代码示例。

970

被折叠的 条评论
为什么被折叠?



