I am creating an attributed string from text received from JSON. I'm then putting that text into a text view.
let descriptionVC = BenefitDescriptionViewController()
let attributedString = try! NSAttributedString(data: descriptionString.data(using: String.Encoding.unicode, allowLossyConversion: true)!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil)
descriptionVC.labelString = attributedString
descriptionVC
override func viewDidLoad() {
super.viewDidLoad()
// print("Attributed String: \(labelString)")
if let descriptionString = labelString {
descriptionTextView.attributedText = descriptionString
descriptionTextView.textColor = UIColor.white
descriptionTextView.font = UIFont.systemFont(ofSize: 17.0)
}
}
I want to keep formatting, such as some of the text being bold, but make the font bigger. When I try to increase the font size, all of the other formatting goes away.
This is what I get when I print labelString.