我想知道如何在
swift中将标题颜色更改为NSButton,我在
objective-c中看到了很多例子,但我认为在swift中实现是不同的,有人能为我提供一个例子吗?
在viewDidLoad或某处尝试此操作.
在Swift 3中:
let pstyle = NSMutableParagraphStyle() pstyle.alignment = .center button.attributedTitle = NSAttributedString(string: "Title",attributes: [ NSForegroundColorAttributeName : NSColor.red,NSParagraphStyleAttributeName : pstyle ])