How to set the color of a string on a NSButton?
How to set the color of a string on a NSButton?
- Subject: How to set the color of a string on a NSButton?
- From: David Hinz <email@hidden>
- Date: Thu, 23 Nov 2006 00:10:07 -0700
What is the easiest way to change the color of the string on a
NSButton where string was set through Interface Builder?
In the -(void)awakeFromNib method I tried getting a
NSMutableAttributeString from the button then using the
setAttributes:range: method. But that doesn't seem to work.
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])];
There must be an easier way to set the text color on a NSButton.
Setting the background color was easy.
[[threeButton cell] setBackgroundColor:[NSColor brownColor]];
Thanks,
David.
_______________________________________________
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