zoukankan      html  css  js  c++  java
  • 修改一个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];

  • 相关阅读:
    团队冲刺0202
    团队冲刺0201
    第十五周
    第十四周博客
    十三周总结
    软件设计模式13
    软件设计模式12
    软件构造4
    软件设计模式11
    软件设计模式10
  • 原文地址:https://www.cnblogs.com/SensenCoder/p/4995475.html
Copyright © 2011-2022 走看看