+ (NSMutableAttributedString *)stringColorStr:(NSString *)str String:(NSString *)string Color:(UIColor*)color{
//Label不同字显示不同颜色
NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@",str,string]];
NSRange redRange = NSMakeRange([[noteStr string] rangeOfString:string].location, [[noteStr string] rangeOfString:string].length);
//需要设置的位置
[noteStr addAttribute:NSForegroundColorAttributeName value:color range:redRange];
return noteStr;
}
调用方式:[label setAttributedText:[RRPPrintObject stringColorStr:@”不变色的字符” String:@”变色的字符” Color:变的颜色];