NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"3569位家认证医院的17539位咨询师期待您的加入"];
[str addAttribute:NSForegroundColorAttributeName value:RGBCOLORA(255, 255, 255, 0.5) range:NSMakeRange(0,str.length)];
[str addAttribute:NSForegroundColorAttributeName value:RGBCOLORA(121, 210, 190, 0.3) range:NSMakeRange(0,4)];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:40] range:NSMakeRange(11, 5)];
[str addAttribute:NSForegroundColorAttributeName value:RGBCOLORA(121, 210, 190, 0.3) range:NSMakeRange(11,5)];
Lable.attributedText = str;
运行效果预览
其中
NSMakeRange
NSMakeRange(NSUInteger loc, NSUInteger len) 从第几个字符到多少个字符间,即length