UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(8, 100, 300, 30)];

    label.textColor = wordGaryColor;  //未专门设置的字体颜色

    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"公司简介:发挥收到后即可圣诞节快发吧士大夫深刻的房价高速度开放和山东矿机山东科技楼粉红是大家分工"];

    [str addAttribute:NSForegroundColorAttributeName value:commonColor range:NSMakeRange(0,5)];

   [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6,12)];
   [str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(19,6)];
   [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:19] range:NSMakeRange(0, 5)];
   [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(6, 12)];
   [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:30.0] range:NSMakeRange(19, 6)];

    label.attributedText = str;

    [self.view addSubview:label];

相关文章:

  • 2022-12-23
  • 2021-09-24
  • 2021-11-21
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-02-14
  • 2022-12-23
相关资源
相似解决方案