iOS text显示不同颜色

拷贝代码备用

NSString *noLabelString = [NSString stringWithFormat:@"[预售]订单号:%@",_order.orderId];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:noLabelString];
NSDictionary *attributesDict = @{NSForegroundColorAttributeName:[VCColor darkRedColor]};
[attributedString addAttributes:attributesDict range:NSMakeRange(0, 4)];
_orderNoLabel.attributedText = attributedString;

你可能感兴趣的:(iOS text显示不同颜色)