Re: UIColor vs. NSColor methods
Re: UIColor vs. NSColor methods
- Subject: Re: UIColor vs. NSColor methods
- From: Roland King <email@hidden>
- Date: Sun, 29 May 2011 13:50:27 +0800
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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden