imzyf / ios-swift-learning-notes

📝 iOS Swift Learning Notes - see Issues
MIT License
0 stars 0 forks source link

UILabel UITextView 的文字行间距 #58

Open imzyf opened 6 years ago

imzyf commented 6 years ago

http://www.hangge.com/blog/cache/detail_1570.html

//通过富文本来设置行间距
        let paraph = NSMutableParagraphStyle()
        //将行间距设置为28
        paraph.lineSpacing = 20
        //样式属性集合
        let attributes = [NSFontAttributeName:UIFont.systemFont(ofSize: 15),
                          NSParagraphStyleAttributeName: paraph]
        label.attributedText = NSAttributedString(string: str, attributes: attributes)