• 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: How to set the color of a string on a NSButton?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set the color of a string on a NSButton?


  • Subject: Re: How to set the color of a string on a NSButton?
  • From: "stephen joseph butler" <email@hidden>
  • Date: Thu, 23 Nov 2006 01:22:21 -0600

2006/11/23, David Hinz <email@hidden>:
The error I got at run time is:
-[NSCFString setAttributes:range:]: selector not recognized [self =
0x34df00]

This is what I tried:

NSDictionary *textDictionary = [NSDictionary dictionaryWithObject:
[NSColor whiteColor]

forKey:NSForegroundColorAttributeName];
[(NSMutableAttributedString *)([[threeButton stringValue]
mutableCopy]) setAttributes:textDictionary
                          range:NSMakeRange(0, [[threeButton
stringValue] length])];

You get that error because what you have is not an NSMutableAttributedString. I don't know if this ultimately does what you want, but it will solve your immediate problem:

NSAttributedString *coloredString = [[[NSAttributedString alloc]
initWithString:[threeButton stringValue] attributes:textDictionary]
autorelease];

[threeButton setStringValue:coloredString];
_______________________________________________

Cocoa-dev mailing list      (email@hidden)

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: How to set the color of a string on a NSButton?
      • From: Nick Zitzmann <email@hidden>
References: 
 >How to set the color of a string on a NSButton? (From: David Hinz <email@hidden>)

  • Prev by Date: Re: How to set the color of a string on a NSButton?
  • Next by Date: Re: How to set the color of a string on a NSButton?
  • Previous by thread: Re: How to set the color of a string on a NSButton?
  • Next by thread: Re: How to set the color of a string on a NSButton?
  • Index(es):
    • Date
    • Thread