Revision: 54339
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 20, 2011 20:15 by mirage3d
Initial Code
- (void)setButtonTitleFor:(NSButton*)button toString:(NSString*)title withColor:(NSColor*)color { 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]; [button setAttributedTitle:attrString]; [style release]; [attrString release]; }
Initial URL
https://discussions.apple.com/message/9334854#9334854
Initial Description
A Modular method to set new text with color of an NSButton. Thanks go to the owner of this code - RayNewbie - in the Apple discussion forum.
Initial Title
Change Color of NSButton
Initial Tags
mac
Initial Language
Objective C