美文网首页
swift label 显示html文本

swift label 显示html文本

作者: 晨煜煌 | 来源:发表于2019-04-10 15:45 被阅读0次
let html = "htmlText: <font color='#FF8B2F'>111111</font>"
do {
    if let data = html.data(using: String.Encoding.unicode, allowLossyConversion: true) {
        let attStr = try NSAttributedString.init(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttributedString.DocumentType.html,], documentAttributes: nil)
        titleLabel.attributedText = attStr
    }
} catch {
    titleLabel.text = html
}

相关文章

网友评论

      本文标题:swift label 显示html文本

      本文链接:https://www.haomeiwen.com/subject/xptoiqtx.html