From server I get a string with html tag, it's like that:
"It's a test - <a href=\"https://apple.com\" target=\"_blank\">Apple</a>""
I use this function to convert it to NSAttributedString
.
func convertHtmlTagsToString(text: String) {
let attributedString = Data(text.utf8)
if let attributedString = try? NSAttributedString(data: attributedString, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil) {
label.attributedText = attributedString
}
}
My first problem is I can't change the color of the label text, it's black, and my second problem is, how I can make the url part clickable that I can open safari with that link.
Thank you so much.