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];

  • 相关阅读:
    月亮,还是馅饼(2)
    月亮,还是馅饼(1)
    spread 论坛
    kaok website
    提升 .NET 程序性能的 一些 原则
    sql convert
    sql 中 MSDTC 不可用。
    判断sql执行所花的时间(精度为毫秒)
    35岁以前成功的12条黄金法则
    快速删除表中的数据
  • 原文地址:https://www.cnblogs.com/zhujin/p/3848420.html
Copyright © 2011-2022 走看看