如何为 NSButton 的标题设置自定义颜色和字体大小?(在 OS X NOT iOS 中)
How can I set a custom color and font size for the title of an NSButton?(in OS X NOT iOS)
例如,假设我有一个名为 Button 的按钮,它的标题是 "Hello"。如何使字体大小为 35 的标题变为红色?
提前感谢您的所有回答!
解决方案:
button.attributedTitle = NSAttributedString(string: "Title", attributes: [ NSForegroundColorAttributeName : NSColor.redColor(), NSFontAttributeName: UIFont(name: "Chalkduster", size: 35.0)!])
例如,假设我有一个名为 Button 的按钮,它的标题是 "Hello"。如何使字体大小为 35 的标题变为红色? 提前感谢您的所有回答!
解决方案:
button.attributedTitle = NSAttributedString(string: "Title", attributes: [ NSForegroundColorAttributeName : NSColor.redColor(), NSFontAttributeName: UIFont(name: "Chalkduster", size: 35.0)!])