NSButtonCell CELL IB ( BUTTON → ). , :
- (NSAttributedString*)attributedTitleForString:(NSString*)string
{
NSColor *disabledColor = [NSColor grayColor];
NSColor *enabledColor = [NSColor redColor];
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setAlignment:NSLeftTextAlignment];
NSFont *font = [NSFont systemFontOfSize:11];
NSDictionary *enabledAttrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
enabledColor, NSForegroundColorAttributeName,
style, NSParagraphStyleAttributeName,
font, NSFontAttributeName,
nil];
NSAttributedString* enabledTitle = [[NSAttributedString alloc]initWithString:string attributes:enabledAttrsDictionary];
NSDictionary *disabledAttrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
disabledColor, NSForegroundColorAttributeName,
style, NSParagraphStyleAttributeName,
font, NSFontAttributeName, nil];
NSAttributedString* disabledTitle = [[NSAttributedString alloc]initWithString:string attributes:disabledAttrsDictionary];
if (![self isEnabled])
return disabledTitle;
else
return enabledTitle;
}
EDIT: setWantsLayers false