如何在iOS中的UILabel上显示带有表情符号的HTML字符串?

时间:2018-03-05 09:33:10

标签: ios swift nsattributedstring

我希望在UILabel中显示带有表情符号的HTML字符串,我已经为显示HTML内容创建了此代码,现在我想显示表情符号,任何人都可以帮助我吗?

func stringFromHtml(string: String) -> NSAttributedString? {
    do {
        let data = string.data(using: String.Encoding.utf8, allowLossyConversion: true)
        if let d = data {
            let str = try NSAttributedString(data: d, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)

            return str
        }
    } catch { }
    return nil
}

0 个答案:

没有答案