Reputation:
My project have button as well as check box with default title color black i want to change color of title to red
Upvotes: 2
Views: 2474
Reputation: 5435
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.
Upvotes: 1