如何使用Swift或在Interface Builder中以编程方式设置多行NSTextField的行间距?
答案 0 :(得分:1)
您可以使用NSAttributedString
来修改此内容(Swift 4示例):
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10.0 // sets the space BETWEEN lines to 10 points
paragraphStyle.maximumLineHeight = 12.0 // sets the MAXIMUM height of the lines to 12 points
let text = "Your text"
let attributes = [.paragraphStyle: paragraphStyle]
textField.attributedStringValue = NSAttributedString(string: text, attributes: attributes)