zoukankan      html  css  js  c++  java
  • NSMutableAttributedString 设置不同颜色,不同字体的String

       UILabel *infoLabel = [[UILabel alloc]initWithFrame:CGRectMake(95, 20, 190, 70)];

        infoLabel.backgroundColor = [UIColor clearColor];

        infoLabel.textAlignment = NSTextAlignmentLeft;

        infoLabel.font = [UIFont systemFontOfSize:13];

        infoLabel.numberOfLines = 0;

        infoLabel.textColor = KSignTextColor;

        NSString *infoString = @"连续签到1天得10积分; 连续签到2天得15积分; 连续签到3天及以上得20积分; 注:若连续签到终端则重新计算";

        NSRange infoRange = [infoString rangeOfString:@"注:"];

        NSMutableAttributedString  *infoATString = [[NSMutableAttributedString alloc]initWithString:infoString ];

        [infoATString addAttribute:NSForegroundColorAttributeName

                            value:[UIColor redColor]

                            range:infoRange];

       // NSRange range = NSMakeRange(infoString.length-1, 1);

        //[infoATString addAttribute:(NSString *)kCTFontAttributeName value:(id)[UIFont systemFontOfSize:10] range:range];

        [infoLabel setAttributedText:infoATString];

  • 相关阅读:
    js实现中文转拼音
    JS中的call、apply、bind方法
    python 过滤html方法
    css 多出一行或多行后显示...的方法
    js 中文排序
    eclipse小技巧
    npm安装及webpack打包小demo
    zan扩展安装
    vagrant安装centos7
    centos7 nginx访问目录403解决
  • 原文地址:https://www.cnblogs.com/zhujin/p/3848420.html
Copyright © 2011-2022 走看看