I've succeeded to display HTML
as attributed String in UILable.
The problem is when that HtmlString is containing href link
nothing happens when you click on that href like the screenshot.
html string example
"The Privacy Policy can be found <a href=\"https://www.w3schools.com/python/python_for_loops.asp\">here</a> "
my code
let stringHTMl = "The Privacy Policy can be found <a href=\"https://www.w3schools.com/python/python_for_loops.asp\">here</a> "
cell.textUILable.attributedText = stringHTMl.convertHtml()
extension for converting stringToattributesHTMLString
func convertHtml() -> NSAttributedString {
guard let data = data(using: .utf8) else { return NSAttributedString() }
do {
return try NSAttributedString(data: data, options: [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)
} catch {
return NSAttributedString()
}
}