个人笔记,不喜勿喷
lab1.attributedText = [下边的方法];
- (NSMutableAttributedString *)getStrWith:(NSString *)str1
str2:(NSString *)changeStr
str3:(NSString *)str3
color:(UIColor *)color{
NSInteger length1 = str1.length;
NSInteger length2 = changeStr.length;
NSString *allStr = [NSString stringWithFormat:@"%@%@%@",str1,changeStr,str3];
NSInteger length3 = allStr.length;
NSMutableAttributedString *resultStr = [[NSMutableAttributedString alloc] initWithString:allStr];
[resultStr addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(length1, length2)];
return resultStr;
}