Search code examples
macoscheckboxspacingnsbutton

OSX - NSButton: set inset of checkbox to title label


I've got an NSButton as a checkbox, and I'd like to set the inset to the title label. Instead of this...

Something like this

Any ideas? In iOS, it can be set via the IB, in OSX apparently not.


Solution

  • Sadly there is nothing in IB for that. So you should do it in the code:

        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.firstLineHeadIndent = 20.0
    
        checkButton.attributedTitle = NSAttributedString(string: checkButton.title, attributes: [NSParagraphStyleAttributeName : paragraphStyle])
    

    Here is how it looks then:

    enter image description here