2

I found this code

let attrStr = try! NSAttributedString(
        data: (text?.data(using: String.Encoding.unicode, allowLossyConversion: true)!)!,
        options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
        documentAttributes: nil)

This returns an attributed string. But the font become too small and different than the one I want. How could I set a default font for that String?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Either your enumerate the NSFontAttributeName and change it, or you add a new HTML tag to change it: http://stackoverflow.com/questions/20992950/ios7-font-size-change-when-create-nsattributedstring-from-html – Larme Aug 24 '16 at 14:25

1 Answers1

2

Just tried something different and I solved:

I did something like that:

text = "<font color=\"black\" face=\"arial\" size=\"15\">" + text + "</font>"

And then used the code above.

Hope that will be useful for someone