富文本改变颜色字体
2017-12-01 本文已影响0人
ljzza
NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@回复%@: %@",model.userName,model.name,model.content]];
[AttributedStr addAttribute:NSForegroundColorAttributeName value:colorWithMainColor range:NSMakeRange(0, model.userName.length)];
[AttributedStr addAttribute:NSForegroundColorAttributeName value:colorWithMainColor range:NSMakeRange(model.userName.length + @"回复".length,model.name.length)];
_titleLabel.attributedText = AttributedStr;
([AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16.0] range:NSMakeRange(0, 5)];)