2

My project have button as well as check box with default title color black i want to change color of title to red

  • Welcome to stackoverflow. Please read http://stackoverflow.com/help/how-to-ask and rewrite your question. Add some code, add some explanation, show what you tried so far. – maxhb Jan 25 '16 at 13:27
  • i want to change just font color of button title –  Jan 25 '16 at 13:29
  • 4
    Possible duplicate of [NSButton how to color the text](http://stackoverflow.com/questions/13109964/nsbutton-how-to-color-the-text) –  Jan 25 '16 at 13:33

1 Answers1

1

Here's the code to set the button title color in a controller:

 NSColor *color = [NSColor greenColor];
 NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
 [style setAlignment:NSCenterTextAlignment];
 NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
 color, NSForegroundColorAttributeName, style, NSParagraphStyleAttributeName, nil];
 NSAttributedString *attrString = [[NSAttributedString alloc]
 initWithString:@"Title" attributes:attrsDictionary];
 [self.button setAttributedTitle:attrString];

may be this is all you want.

Ronak Chaniyara
  • 5,335
  • 3
  • 24
  • 51