UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(100,100,200,30)];
NSString *balance =@"6666";
NSMutableAttributedString *aString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"价格: %@元",balance]];
[aString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor]range:NSMakeRange(6, balance.length)];
[aString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15]range:NSMakeRange(6, balance.length)];
label.attributedText= aString;
[self.view addSubview:label];
网友评论