2016-07-08 45 views
5

Nella mia app ho un'etichetta di avvolgimento (etichetta multilinea) che richiede una regolazione dell'interlinea. Come faccio a impostare l'interlinea per questo NSTextField usando Swift o Interface Builder?Spaziatura linea NSTextField in Swift

risposta

0

È possibile utilizzare NSAttributedString di modificare il presente (Swift 4 esempio):

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 
Problemi correlati