UILabel *fistLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 200, 20)];
fistLabel.textColor = [UIColor darkGrayColor];
fistLabel.font = [UIFont systemFontOfSize:14.0f];
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc]initWithString:@"合计:¥80.00(免运费)"];
NSRange redRange = NSMakeRange([[attributeString string] rangeOfString:@"¥80.00"].location, [[attributeString string] rangeOfString:@"¥80.00"].length);
self.attributeString = attributeString;
[attributeString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange];
[fistLabel setAttributedText:attributeString];
[fistLabel sizeToFit];
[footerView addSubview:fistLabel];
本文介绍如何使用Objective-C为UILabel设置带有不同样式属性的文本,包括颜色、字体大小等,并通过NSMutableAttributedString实现特定部分文字的颜色变化。

8703

被折叠的 条评论
为什么被折叠?



