How to show an HTML string on a UILabel in iOS?

前端 未结 7 1931
心在旅途
心在旅途 2020-12-12 18:25

I am getting a title in HTML format as

Example

I

7条回答
  •  不知归路
    2020-12-12 18:36

    Swift 4+

    For Swift 4 and above use:

    guard let data = "foo".data(using: String.Encoding.unicode) else { return }
    
    try? titleLabel.attributedText = 
       NSAttributedString(data: data,
                       options: [.documentType:NSAttributedString.DocumentType.html], 
            documentAttributes: nil)
    

提交回复
热议问题