多色label
- (void)colorLabel:(UILabel *)label stringOne:(NSString *)stringOne stringTwo:(NSString *)stringTwo colorOne:(UIColor *)colorOne colorTwo:(UIColor *)colorTwo{
NSString *mStringTransmitted = [NSString stringWithFormat:@"%@%@",stringOne,stringTwo];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:mStringTransmitted];
//分别为指定的区间设置不同的颜色
[str addAttribute:NSForegroundColorAttributeName value:colorOne range:NSMakeRange(0,stringOne.length)];
[str addAttribute:NSForegroundColorAttributeName value:colorTwo range:NSMakeRange(stringOne.length,stringTwo.length)];
//_transmittedLabel是一个全局的UILabel
label.attributedText = str;
}