设置字体颜色
2016-01-12 本文已影响2976人
袏扌戒指
- (void)setButtonColor:(NSButton*)button andColor:(NSColor*)color {
if(color ==nil) {
color = [NSColor redColor];
}
NSFont *font = button.font;
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:font,
NSFontAttributeName,
color,
NSForegroundColorAttributeName,
nil];
NSAttributedString* attributedString = [[NSAttributedString alloc] initWithString:[button title] attributes:attrs];
[button setAttributedTitle:attributedString];
}