Answers for "swift aztec present html"

4

swift set html text

extension String {
    var htmlToAttributedString: NSAttributedString? {
        guard let data = data(using: .utf8) else { return NSAttributedString() }
        do {
            return try NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil)
        } catch {
            return NSAttributedString()
        }
    }
    var htmlToString: String {
        return htmlToAttributedString?.string ?? ""
    }
}

textView.attributedText = htmlText.htmlToAttributedString
Posted by: Guest on March-04-2020

Code answers related to "swift aztec present html"

Code answers related to "Swift"

Browse Popular Code Answers by Language