我希望在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
}