Swift 富文本属性设置

        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


  http://blog.csdn.net/bitcser/article/details/56280925

你可能感兴趣的:(Swift,swift,富文本属性)