设置Label部分字体颜色和大小

NSString *str = [NSString stringWithFormat:@"(推荐) %@",_phoneNumber];

_subtitleLabel.text = str;

NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:_subtitleLabel.text];

[attr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 4)];

[attr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10] range:NSMakeRange(0, 4)];

[_subtitleLabel setAttributedText:attr];

你可能感兴趣的:(设置Label部分字体颜色和大小)