How to display html formatted text in ios label

前端 未结 7 1374
逝去的感伤
逝去的感伤 2020-12-24 00:55

I would like to display html formatted text on a UILabel in IOS.

In Android, it has api like this .setText(Html.fromHtml(somestri

7条回答
  •  伪装坚强ぢ
    2020-12-24 01:56

    You could try an attributed string:

    var attrStr = NSAttributedString(
            data: "text".dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true),
            options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
            documentAttributes: nil,
            error: nil)
    label.attributedText = attrStr
    

提交回复
热议问题