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

  • 相关阅读:
    20191105 《Spring5高级编程》笔记-第10章
    Overview of the High Efficiency Video Coding (HEVC) Standard阅读笔记
    web视频播放
    ffmpeg使用笔记
    ffplay使用笔记
    ffmpeg安装配置以及库调用
    ffmpeg入门
    Faster-RCNN
    OJ练习
    python搭建友盟以及个推推送web服务器
  • 原文地址:https://www.cnblogs.com/zhujin/p/3848420.html
Copyright © 2011-2022 走看看