So I am trying to get the following code to work
return try NSAttributedString(data: data, attributes:[ NSFontAttributeName: UIFont(name: "Chalkduster", size: 18.0) ], options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil)
I have tried the following too but just fails
extension String {
var htmlToAttributedString: NSAttributedString? {
guard let data = data(using: .utf8) else { return NSAttributedString() }
do {
let font = UIFont.systemFont(ofSize: 72)
let attributes = [NSAttributedString.Key.font: font]
return try NSAttributedString(data: data, attributes: attributes, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding:String.Encoding.utf8.rawValue], documentAttributes: nil)
} catch {
return NSAttributedString()
}
}
var htmlToString: String {
return htmlToAttributedString?.string ?? ""
}
}
tags and
tags nothing more
– RussellHarrower Dec 12 '19 at 01:02