UILabel * goodtotalLabel = [UILabel new];
goodtotalLabel.textColor = ZDColor_Red;
//原来label文字的颜色
NSMutableAttributedString *hintString =[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"总计:¥ %.2f ",sum]];
//获取要调整颜色的文字位置
NSRange range =[[hintString string]rangeOfString:@"总计:¥"];
[hintString addAttribute:NSForegroundColorAttributeName value:ZDColor_Black range:range];
goodtotalLabel.attributedText = hintString;
iOS label的文字显示不同的颜色
最新推荐文章于 2021-05-26 01:19:28 发布