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

Question about color


  • Subject: Question about color
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Thu, 5 Aug 2010 13:45:12 -0400

This is a noob question, and as I pour through the docs, I thought I would
ask here too.

I have buttons that have different text colors. All I would like to do is to
check the color after it's been clicked.

-(void) aButtonWasClicked:(id)sender
{

UIButton* resultButton = (UIButton*)sender;

UIColor *color = [resultButton titleColorForState:UIControlStateNormal];

NSLog(@"%@",color);

}

>From this I get either:

<CGColor 0x59549d0> [<CGColorSpace 0x59269c0> (kCGColorSpaceDeviceGray)] (
0.5 1 )
or
<CGColor 0x5952970> [<CGColorSpace 0x59218e0> (kCGColorSpaceDeviceRGB)] (
0.22 0.33 0.53 1 )

If I change to NSLog to use color.CGColor instead, I get either:

<CGColor 0x794d8e0> [<CGColorSpace 0x792b860> (kCGColorSpaceDeviceGray)] (
0.5 1 )
or
<CGColor 0x794b8a0> [<CGColorSpace 0x7909020> (kCGColorSpaceDeviceRGB)] (
0.22 0.33 0.53 1 )

How can I check what the color is in order to manipulate the button after
it's pressed? If it's gray, do one thing, if it's another color, do
something else. I'm not sure how to run an if on it yet.

if( something == ? ){
     //it's greyscale
} else {
     //It's colored
}

Thanks in advance.




Interactive Designer and Developer
_______________________________________________

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: Question about color
      • From: Nick Zitzmann <email@hidden>
    • Re: Question about color
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: Resolution of an NSImage(Rep)?
  • Next by Date: Re: Question about color
  • Previous by thread: iOS4: remote / headset events and the remote control display
  • Next by thread: Re: Question about color
  • Index(es):
    • Date
    • Thread