• 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: Question about color
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about color


  • Subject: Re: Question about color
  • From: Nick Zitzmann <email@hidden>
  • Date: Thu, 5 Aug 2010 12:19:38 -0600

On Aug 5, 2010, at 12:13 PM, Eric E. Dolecki wrote:

> Not that I am going forward with this, but this seems to determine if the color is b/w/gray or color:
>
> -(void) buttonClicked:(id)sender {
>     UIButton *resultButton = (UIButton *)sender;
>     UIColor *color = [resultButton titleColorForState:UIControlStateNormal];
>     CGColorRef color2 = [color CGColor];
>     int numComponents = CGColorGetNumberOfComponents(color2);
>
>     if( numComponents == 2 ){
>         //gray (value of black and alpha)
>     } else {
>         //color
>     }
> }

And of course, that won't pick up the case where the color is RGB and the components are the same, or if it's a grey CMYK color. So, yeah, you shouldn't branch on colors.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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

References: 
 >Question about color (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Question about color (From: Nick Zitzmann <email@hidden>)
 >Re: Question about color (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: Question about color
  • Next by Date: Re: Resolution of an NSImage(Rep)?
  • Previous by thread: Re: Question about color
  • Next by thread: Coercion exception assigning a Core Data property
  • Index(es):
    • Date
    • Thread