S.Shahsiah S.Shahsiah - 1 year ago 140
Swift Question

How can I set a custom color and font size for the title of an NSButton?(in OS X NOT iOS)

For example consider I have a button named Button and its title is "Hello" . How can I make the title red colored with a font size of 35?
Thanks for all your answers in advance!

Answer Source


    button.attributedTitle = NSAttributedString(string: "Title", attributes: [ NSForegroundColorAttributeName : NSColor.redColor(),  NSFontAttributeName: UIFont(name: "Chalkduster", size: 35.0)!])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download