use*_*395 5 macos cocoa nstextfield 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)
Run Code Online (Sandbox Code Playgroud)