主要代码
let location = att.string.range(of: "\(count)")
NSRange(location, in: att.string)
let count: Int = 56
let att = NSMutableAttributedString(string: "\(count)件礼物")
guard let location = att.string.range(of: "\(count)") else {
return
}
let range = NSRange(location, in: att.string)
att.yy_setAttribute(NSAttributedString.Key.font.rawValue, value: UIFont.systemFont(ofSize: 13), range: range)
att.yy_setAttribute(NSAttributedString.Key.foregroundColor.rawValue, value: UIColor(colorType: .C34), range: range)
haveLightLabel.attributedText = att
网友评论