let model:JYDiagnoseModel = modelArr[indexPath.row] as! JYDiagnoseModel
let hitString = NSMutableAttributedString.init(string: "["+model.itemCode!+"]"+model.itemCnName!)
let range = NSRange.init(location: 0, length: (model.itemCode?.characters.count)!+2)
hitString.addAttributes([NSForegroundColorAttributeName:UIColor.main()], range: range)
cell?.textLabel?.attributedText = hitString
其他属性参考楼主另一篇文章
iOS AttributedString