swift3.0 label行高extension封装

前端之家收集整理的这篇文章主要介绍了swift3.0 label行高extension封装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
class func lineSpacing(_ content: String,_ space: Int) -> NSAttributedString {
        let attributedString:NSMutableAttributedString = NSMutableAttributedString(string: content)
        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.lineSpacing = CGFloat(space)
        paragraphStyle.alignment = .right
        attributedString.addAttribute(NSParagraphStyleAttributeName,value: paragraphStyle,range: NSMakeRange(0,content.characters.count))
        return attributedString
    }

猜你在找的Swift相关文章