// 提示字符串 tips:是服务器返回的HTML字符串
lazy var tipsString : NSAttributedString? = {
let data = tips?.data(using: String.Encoding.unicode) ?? Data()
do {
var attributedString = try NSMutableAttributedString.init(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttributedString.DocumentType.html], documentAttributes: nil)
//设置行间距,同样可以根据具体情况设置其他属性。
let paraph = NSMutableParagraphStyle()
paraph.lineSpacing = 10
attributedString.addAttributes([NSAttributedStringKey.paragraphStyle: paraph], range: NSMakeRange(0, attributedString.length))
return attributedString
} catch let error {
Mprint(error)
}
return nil
}()
网友评论