I am dinamically getting an HTML string from a Wordpress API and parsing it into an Attributed String to show it in my app. Since the string has its own styles, it shows different fonts and sizes, something that is affecting our design choices.
What I want to do is change the font and its size on the whole attributed string.
I tried doing so in the options of the attributed string, but it does nothing:
let attributedT = try! NSAttributedString(
data: nContent!.decodeHTML().data(using: String.Encoding.unicode, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSFontAttributeName: UIFont(name: "Helvetica", size: 16.0)!],
documentAttributes: nil)
contentLbl.attributedText = attributedT
Does anybody have any ideas on how to achieve this?
P.S. I know that I could add a CSS tag to the beginning or end of the string, but would this override other styles in it? Also, if this is a valid solution, could you please provide a sample on how to do it?