Swift加载Html文本

      let str = "Html文本"
      var content = UILabel()
      guard let news = str.removingPercentEncoding,let data = news.data(using: .unicode) else{return}
      let att = [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html]
      guard let attStr = try? NSMutableAttributedString(data: data, options: att, documentAttributes: nil) else{return}
      content.attributedText = attStr

你可能感兴趣的:(Swift加载Html文本)