Hi I have a UILabel named questionLabel
let exStr = "SOME HTML STRING CONTAINING BOLD AND ITALIC WORDS"
var exAttrStr = try! NSMutableAttributedString(data: exStr.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!,
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, namedNSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding],
documentAttributes: nil)
exAttrStr.addAttribute(NSForegroundColorAttributeName, value: UIColor(colorLiteralRed: 51/255, green: 53/255, blue: 51/255, alpha: 1), range: NSRange(location:0,length:exAttrStr.length))
exAttrStr.addAttribute(NSFontAttributeName , value: SharedConstants.textFontSFUITextRegular(15), range: NSRange(location:0,length:exAttrStr.length))
questionLabel.attributedText = exAttrStr
I am setting the font as SFUIText
regular. As I am adding attributes to the exAttrStr
the bold and italic part of the attributed text is being overwritten. Is there a way I could get the bold and italic words using the SFUIText
font family.