从10.9开始,NSButtonCell的setFont方法似乎不再可用。
是否有任何方法(或类别)来实现它?
我不知道为什么苹果会把自己的风格强加在按钮上。
我尝试了两天的风格,我自己的定制按钮(我还需要一个类别,以简单地改变按钮的文字颜色-耻辱)。
发布于 2015-05-16 13:58:42
您可以使用-setAttributedTitle: of NSButton设置按钮标题的样式。
样本代码:
NSDictionary *attributes = @{NSForegroundColorAttributeName: [NSColor redColor], NSFontAttributeName: [NSFont userFixedPitchFontOfSize:13.0f]};
NSAttributedString *aString = [[NSAttributedString alloc] initWithString:@"Button" attributes:attributes];
[button setAttributedTitle:aString];

https://stackoverflow.com/questions/29984536
复制相似问题