• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UIColor vs. NSColor methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: UIColor vs. NSColor methods
      • From: Graham Cox <email@hidden>
    • Re: UIColor vs. NSColor methods
      • From: Kyle Sluder <email@hidden>
References: 
 >UIColor vs. NSColor methods (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: What's wrong with this?
  • Next by Date: Re: QuickTime Player - like application
  • Previous by thread: UIColor vs. NSColor methods
  • Next by thread: Re: UIColor vs. NSColor methods
  • Index(es):
    • Date
    • Thread