NSButton Set Text Color?
Is there a way to set the text color of a title in an NSButton in my code? I've been looking things up and trying for a bit now and I've come to the conclusion that, if you can do it, it's quite elaborate. Then again, I forgot a stupid thing with my last question so that may be the case again.
I'm pretty sure doing so goes against the Apple Human Interface Guidelines. That said, here's how it can be done:
Code:
NSColor *color = [NSColor redColor];
NSMutableAttributedString *colorTitle =
[[NSMutableAttributedString alloc] initWithAttributedString:[button attributedTitle]];
NSRange titleRange = NSMakeRange(0, [colorTitle length]);
[colorTitle addAttribute:NSForegroundColorAttributeName
value:color
range:titleRange];
[button setAttributedTitle:colorTitle];
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Getting text from a window text field | mars | 7 | 4,325 |
Mar 26, 2005 06:06 PM Last Post: OneSadCookie |
|

