后天(腊月25)就放年假了,这两天坐等老大发微信红包
改变字体颜色代码用法:
- (void)viewDidLoad {
NSRange range = [_amountLabel.text rangeOfString:@"0.00"];
[self setTextColor:_amountLabel FontNumber:[UIFont systemFontOfSize:13] AndRange:range AndColor:[UIColor orangeColor]];
}
//设置不同字体颜色
-(void)setTextColor:(UILabel *)label FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor
{
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:label.text];
//设置字号
[str addAttribute:NSFontAttributeName value:font range:range];
//设置文字颜色
[str addAttribute:NSForegroundColorAttributeName value:vaColor range:range];
label.attributedText = str;
}
效果: