2016-07-08 3 views
5

私は、行間調整が必要なアプリケーションにラッピングラベル(複数行ラベル)を持っています。 SwiftやInterface Builderを使って、このNSTextFieldの行間隔を設定するにはどうしたらいいですか?NSTextField Line Swacingでの間隔

答えて

0

あなたがこの(スウィフト4例)を変更するためにNSAttributedStringを使用することができます。

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