Re: How to set the color of a string on a NSButton?
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