我正在尝试将af的contribString实现到UILabel中,但我一直在跟踪错误。 Command failed due to signal: Segmentation fault 11
。我正在使用xcode 8 beta和swift 3.0。
let attributedString = NSMutableAttributedString(string: titleText, attributes: [NSFontAttributeName:UIFont(name: "Avenir-Book", size: 14)])
let boldFontAttribute = [NSFontAttributeName: UIFont(name: "Avenir-Medium ", size: 14)]
// Part of string to be bold
attributedString.addAttributes(boldFontAttribute, range: titleText.rangeOfString("Anytime. Anywhere."))
introTextLabel.attributedText = attributedString
答案 0 :(得分:1)
作为我对您原始帖子的评论的后续跟进,这对我有用(titleText
是一个快捷的字符串):
let attributedString = NSMutableAttributedString(string: titleText, attributes: [NSFontAttributeName: UIFont(name: "Avenir-Book", size: 14)!])
let boldFontAttribute = [NSFontAttributeName: UIFont(name: "Avenir-Medium", size: 14)!]
// Part of string to be bold
attributedString.addAttributes(boldFontAttribute, range: (titleText as NSString).range(of: "Anytime. Anywhere."))
introTextLabel.attributedText = attributedString