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
  • 相关阅读:
    jQuery选择器
    jquery处理json笔记
    观察者模式
    shiro自定义realm
    AysncTask更新progressbar
    android自定义控件
    任务的挂起和激活
    main方法添加2个集合存储图形
    矩形类-内部类刷新
    圆类-内部类多线程刷新
  • 原文地址:https://www.cnblogs.com/zuidap/p/5764086.html
Copyright © 2011-2022 走看看