My app get some HTML formatted text from a website and I would like to change the font size of the NSAttributedString
and display it in a textview
var htmlString : String //the html formatted text
textView.attributedText = handleHtml(htmlString) // this is how I call the function, but the font size didn't change
func handleHtml(string : String) -> NSAttributedString{
let attrs = [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSFontAttributeName: UIFont.systemFontOfSize(20.0)]
var returnStr = NSAttributedString()
do {
returnStr = try NSAttributedString(data: string.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!, options: attrs, documentAttributes: nil)
} catch {
print(error)
}
return returnStr
}
I tried [NSFontAttributeName: UIFont.systemFontOfSize(20.0)]
as shown in the above code but the font size didn't changed.