富文本改变颜色字体

        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)];)

你可能感兴趣的:(富文本改变颜色字体)