zoukankan      html  css  js  c++  java
  • label 不同颜色

    label  不同颜色

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

        noteLabel.frame = CGRectMake(60, 100, 200, 100);

        noteLabel.textColor = [UIColor blackColor];

        noteLabel.numberOfLines = 2;

        

        NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:@"点击注册按钮,即表示您已同意隐私条款和服务协议"];

        NSRange redRange = NSMakeRange([[noteStr string] rangeOfString:@"注册"].location, [[noteStr string] rangeOfString:@"注册"].length);

        [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange];

        NSRange redRangeTwo = NSMakeRange([[noteStr string] rangeOfString:@"同意"].location, [[noteStr string] rangeOfString:@"同意"].length);

        [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:redRangeTwo];

       

        [noteLabel setAttributedText:noteStr];

        [noteLabel sizeToFit];

        [self.view addSubview:noteLabel];

    群号:186052819
  • 相关阅读:
    mysql事务
    python zip dict函数
    有关mysql索引
    hash(散列函数)
    Docker使用
    Mac终端命令自动补全
    python序列化与反序列化(json与pickle)
    python txt、excel读写
    python 正则表达式
    python进行数据预处理-pandas
  • 原文地址:https://www.cnblogs.com/zuidap/p/5764086.html
Copyright © 2011-2022 走看看