//从字符串中找到审核、回复
NSString * creat1 =@"回复";
NSString * creat2 =@"私信";
//总的字符串
NSString * showLabel = [NSStringstringWithFormat:@"%@ %@",self.frameModel.chatModel.name,self.frameModel.chatModel.time];
NSMutableAttributedString *AttributedStr = [[NSMutableAttributedStringalloc]initWithString:showLabel];
NSRange range;
//判断字符串中有没有回复
if([showLabelrangeOfString:@"回复"].location !=NSNotFound){
range = [showLabel rangeOfString:creat1];
[AttributedStr addAttribute:NSForegroundColorAttributeName
value:MainTabBarColor
range:NSMakeRange(range.location, range.length)];
}
else{//没有回复那就默认判断审核
range = [showLabel rangeOfString:creat2];
[AttributedStr addAttribute:NSForegroundColorAttributeName
value:[UIColorredColor]
range:NSMakeRange(range.location, range.length)];
}
//添加到UILabel中显示
self.name.attributedText = AttributedStr;