You can use CGColorGetComponents on a CGColorRef to get the values of whatever 
colorspace the CGColorRef is in and you can create new CGColorRefs with those 
values. 

I don't see a way to convert from one colorspace to another however a quick 
test on one UIColor constructed with HSV values shows its contained CGColorRef 
to have an RGB colorspace which you could get the RGB values from. Whether you 
can rely on that I don't know and haven't found any documentation to back it 
up. 

On 29-May-2011, at 11:13 AM, Graham Cox wrote:

> I'm porting some code to iOS from MacOS for the first time.
> 
> I find that UIColor is quite impoverished compared to NSColor, but I also 
> don't see a way to do what I need using CGColorRef either.
> 
> Specifically, I often generate colours from other colours by using the H, S 
> and V values returned by an RGB NSColor. While I can create a UIColor using 
> HSV, I can't see any methods for obtaining those component values. Similarly 
> I can't see how to get the r, g and b components. Likewise there are no HSV 
> <--> RGB functions in the CGColorRef functions either.
> 
> Is there any way to do this using UIColor or CGColor?
> 
> --Graham
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
> 
> This email sent to r...@rols.org

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to