OSX - NSButton:设置标题标签复选框的插入

时间:2016-07-01 15:28:14

标签: macos checkbox spacing nsbutton

我有一个NSButton作为复选框,我想将插图设置为标题标签。 Instead of this...

Something like this

有什么想法吗? 在iOS中,它可以通过IB设置,在OSX中显然不是。

1 个答案:

答案 0 :(得分:3)

遗憾的是,IB没有任何内容。所以你应该在代码中做到这一点:

    let paragraphStyle = NSMutableParagraphStyle()
    paragraphStyle.firstLineHeadIndent = 20.0

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

以下是它的外观:

enter image description here

相关问题