修改一个Label上字体的大小(富文本)

假如修改上面的Label上价格30000的大小,那么需要用到富文本

上代码

// 字符串30000

 NSString * priceNumber = @"30000";

[priceNumber length];

    NSLog(@"%lu",(unsigned long)[priceNumber length]);

    _price = [[UILabel alloc] initWithFrame:CGRectMake(0,100,200,100)];

    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%@/人",priceNumber]];

    [attriString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:25] range:NSMakeRange(1, [priceNumber length])];

    _price.attributedText = attriString;

    [self.view addSubview:_price];

 

相关文章:

  • 2022-12-23
  • 2021-04-14
  • 2021-05-23
  • 2021-07-09
  • 2021-11-12
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
  • 2021-10-02
  • 2021-12-27
  • 2022-12-23
相关资源
相似解决方案