改变指定字体的颜色,
range:NSMakeRange(4, 4)
改变字体的位置和个数
self.enrollLabel
self.person_name
为创建UILabel的对象名字
// 改变颜色
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"一键报名3400元特惠班 品质服务 低价学车"]];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(4, 4)];
self.enrollLabel.attributedText = str;
// 改变字体大小
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"一键报名3400元特惠班 品质服务 低价学车"];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0,5)];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(6,9)];
self.person_name.attributedText = str;