NSString *str1 =@"您的订单已经分配给";
NSInteger length1 = [str1 length];
NSString *nameStr =@"王先生";
NSInteger length2 = [nameStr length];
NSString *str2 = [NSString stringWithFormat:@"%@%@,TA会尽快跟您联系,祝您生活愉快!", str1, nameStr];
NSMutableAttributedString *str3 = [[NSMutableAttributedString alloc] initWithString: str2]; //创建一个NSMutableAttributedString
[str3 addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(length1, length2)]; // 关键步骤,设置指定位置文字的颜色
[str3 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:24.0f] range:NSMakeRange(length1, length2)]; //关键步骤,设置指定位置文字的字号大小
self.textLabel.attributedText = str3;
self.textLabel.numberOfLines = 0;