您好我有一个名为questionLabel的UILabel
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
我将字体设置为SFUIText
常规。当我向exAttrStr
添加属性时,属性文本的粗体和斜体部分将被覆盖。有没有办法可以使用SFUIText
字体系列获得粗体和斜体字。