zoukankan      html  css  js  c++  java
  • 改变label中的某字体颜色

     NSString *allString=@"你家在哪里,需要我送你么";

        NSString *subString=@"在哪里";

        UILabel *stringLabel=[[UILabel alloc]init];

        stringLabel.frame=CGRectMake(0, 100, 300, 30);

        stringLabel.font=[UIFont systemFontOfSize:17];

        stringLabel.backgroundColor=[UIColor blackColor];

        stringLabel.text=allString;

        stringLabel.textColor=[UIColor whiteColor];

        [self.view addSubview:stringLabel];

        

        NSString *allS=[allString lowercaseString];

        NSString *subS=[subString lowercaseString];

        NSRange range=[allS rangeOfString:subS];

        if (range.location!=NSNotFound) {

            NSMutableAttributedString  *string=[[NSMutableAttributedString alloc]initWithString:allString];

            [string addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:range];

            stringLabel.attributedText=string;

        }

  • 相关阅读:
    bp算法原理
    bp算法
    Python之简单的神经网络
    人工智能教程
    clickhouse的windowFunnel(漏斗)
    Hihocoder 1079 离散化
    Hihocoder 1063 缩地
    md5
    搜索引擎 中文分词
    Hihocoder 1059 String Matching Content Length
  • 原文地址:https://www.cnblogs.com/106dapeng/p/4675987.html
Copyright © 2011-2022 走看看