Swift 富文本显示网页内容
2024-02-05 本文已影响0人
xiaofu666
let html = "网页内容"
if let nsAttributedString = try? NSAttributedString(data: Data(html.utf8), options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil),
let attributedString = try? AttributedString(nsAttributedString, including: \.uiKit) {
Text(attributedString)
} else {
Text(html)
}