当前位置:   article > 正文

ios-NSMutableAttributedString 更改文本字符串颜色、大小

ios nsmutableattributedstring设置文本颜色

  1. NSString * string = [NSString stringWithFormat:@"您的号码是%@号",[self backString:dic[@"rankNumber"]]];
  2. NSString * rankNumber = [NSString stringWithFormat:@"%@",[self backString:dic[@"rankNumber"]]];
  3. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:string];
  4. [str addAttribute:NSForegroundColorAttributeName value:YellowColor range:NSMakeRange(5,rankNumber.length)];//(5,2) 2是位数
  5. [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:FontOfSize19*kWidth] range:NSMakeRange(5, rankNumber.length)];
  6. _orderNumber.attributedText = str;
  7. NSString * string1 = [NSString stringWithFormat:@"您前面还有%@位司机在等待",[self backString:dic[@"frontNumber"]]];
  8. NSString * frontNumber = [NSString stringWithFormat:@"%@",[self backString:dic[@"frontNumber"]]];
  9. NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:string1];
  10. [str1 addAttribute:NSForegroundColorAttributeName value:YellowColor range:NSMakeRange(5,frontNumber.length)];//(5,2) 2是位数
  11. [str1 addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:FontOfSize19*kWidth] range:NSMakeRange(5, frontNumber.length)];
  12. _waitNumber.attributedText = str1;
  13. NSString * number = [NSString stringWithFormat:@"待运单%@",[self backString:dic[@"orderNumber"]]];
  14. _waitOrder.text = number;

 

转载于:https://www.cnblogs.com/sayimba/p/6053325.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/729123
推荐阅读
相关标签
  

闽ICP备14008679号