NSButton Set Text Color?

Posts: 1,066
Joined: 2004.07
Post: #1
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.
Quote this message in a reply
Posts: 208
Joined: 2005.04
Post: #2
I'm pretty sure doing so goes against the Apple Human Interface Guidelines. That said, here's how it can be done:

NSColor *color = [NSColor redColor];
    NSMutableAttributedString *colorTitle =
        [[NSMutableAttributedString alloc] initWithAttributedString:[button attributedTitle]];
    NSRange titleRange = NSMakeRange(0, [colorTitle length]);
    [colorTitle addAttribute:NSForegroundColorAttributeName
    [button setAttributedTitle:colorTitle];
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Getting text from a window text field mars 7 5,281 Mar 26, 2005 06:06 PM
Last Post: OneSadCookie