如何为NSButton的标题设置自定义颜色和字体大小?(在OS X中不是iOS)

时间:2016-05-13 17:58:47

标签: swift macos cocoa swift2 xcode7

例如,考虑我有一个名为Button的按钮,其标题为“Hello”。如何将标题设置为红色,字体大小为35? 提前感谢您的所有答案!

1 个答案:

答案 0 :(得分:3)

<强> SOLUTION:

    button.attributedTitle = NSAttributedString(string: "Title", attributes: [ NSForegroundColorAttributeName : NSColor.redColor(),  NSFontAttributeName: UIFont(name: "Chalkduster", size: 35.0)!])
相关问题