Swift 中的 NSTextField 行间距
NSTextField Line Spacing in Swift
如何使用 Swift 或在 Interface Builder 中以编程方式设置多行 NSTextField 的行间距?
你可以用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)
如何使用 Swift 或在 Interface Builder 中以编程方式设置多行 NSTextField 的行间距?
你可以用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)