NSString*reslutStr =@"27十二月";
NSMutableAttributedString*attriString = [[NSMutableAttributedStringalloc]initWithString:reslutStr];
[attriStringaddAttribute:NSForegroundColorAttributeName//文字颜色
value:[UIColororangeColor]
range:NSMakeRange(2,reslutStr.length-2)];
cell.timeLabel.attributedText= attriString;
+ (void)setUILabel:(UILabel*)label Data:(NSString*)string SetData:(NSString*)setstring Color:(UIColor*)color Font:(CGFloat)font Underline:(BOOL)isbool{
NSRangestr = [label.textrangeOfString:setstring];
if(str.location!=NSNotFound) {
NSMutableAttributedString*str1 = [[NSMutableAttributedStringalloc]initWithString:label.text];
[str1addAttribute:NSForegroundColorAttributeNamevalue:colorrange:NSMakeRange(string.length,setstring.length)];//设置字体颜色
[str1addAttribute:NSFontAttributeNamevalue:[UIFontsystemFontOfSize:font]range:NSMakeRange(string.length,setstring.length)];
if(isbool) {
//是否显示下划线
[str1addAttribute:NSStrikethroughStyleAttributeNamevalue:@(NSUnderlinePatternSolid|NSUnderlineStyleSingle)range:NSMakeRange(string.length,setstring.length)];
}
label.attributedText= str1;
}
}