zoukankan      html  css  js  c++  java
  • 改变字符串中部分字符传的字体大小和颜色

    - (void)viewDidLoad {
    NSRange range = [_amountLabel.text rangeOfString:@"0.00"];
        [self setTextColor:_amountLabel FontNumber:[UIFont systemFontOfSize:13] AndRange:range AndColor:[UIColor orangeColor]];
        }
    
    
    //设置不同字体颜色
    -(void)setTextColor:(UILabel *)label FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor
    {
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:label.text];
        //设置字号
        [str addAttribute:NSFontAttributeName value:font range:range];
        //设置文字颜色
        [str addAttribute:NSForegroundColorAttributeName value:vaColor range:range];
    
        label.attributedText = str;
    }
  • 相关阅读:
    leetcode
    leetcode
    leetcode
    leetcode
    Postman
    Fiddler抓百度和bing搜索包
    Jmeter脚本录制
    Android Studio使用Maven国内镜像
    Open Live Writer
    PureXXX使用手记
  • 原文地址:https://www.cnblogs.com/pioneerMax/p/6081310.html
Copyright © 2011-2022 走看看