2016-07-08 28 views
5

Ich habe ein Verpackungsetikett (mehrzeiliges Etikett) in meiner App, das eine Anpassung des Zeilenabstands benötigt. Wie kann ich den Zeilenabstand für dieses NSTextField mit Swift oder dem Interface Builder einstellen?NSTextField Zeilenabstand in Swift

Antwort

0

Sie können NSAttributedString verwenden diese (Swift 4 Beispiel) zu ändern:

let title:String = "Your text" 
    let textParagraph:NSMutableParagraphStyle = NSMutableParagraphStyle() 
    textParagraph.lineSpacing = 10.0 /*this sets the space BETWEEN lines to 10points */ 
    textParagraph.maximumLineHeight = 12.0/*this sets the MAXIMUM height of the lines to 12points */ 
    let attribs = [NSAttributedStringKey.paragraphStyle:textParagraph] 
    let attrString:NSAttributedString = NSAttributedString.init(string: title, attributes: attribs) 
    titleTextField.attributedStringValue = attrString