zoukankan      html  css  js  c++  java
  • NSMutableAttributedString addAttributes增加颜色无效的问题

    下面是代码,被注释掉的是原来的代码,指定颜色不生效。

    NSMutableAttributedString *attriString = [[[NSMutableAttributedStringalloc] initWithString:string] autorelease];

        NSRange range;

        range.location = 4;

        range.length = nameString.length;

        [attriString removeAttribute:(NSString *)kCTFontAttributeNamerange:range];

        if ([SYSTEM_VERSION intValue] >= 6.0) {

            [attriString addAttribute:NSForegroundColorAttributeNamevalue:[UIColorredColor] range:range];

        }

        else{

            [attriString addAttribute:(NSString *)kCTForegroundColorAttributeNamevalue:(id)[UIColorredColor].CGColorrange:range];

        }

        [attriString addAttribute:(NSString *)kCTFontAttributeNamevalue:(id)[UIFontsystemFontOfSize:15] range:range];

    //    [attriString addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:

    //                               (id)[UIFont systemFontOfSize:15],(NSString *)kCTFontAttributeName,

    //                                (id)RGBCOLOR(0, 255, 255),(NSString *)kCTForegroundColorAttributeName,

    //                                nil]

    //                         range:range];

        [self.auntName setAttributedText:attriString];

  • 相关阅读:
    C#Redis集合set
    C#Redis列表List
    C#Redis字符串
    C#Redis初识
    2016-2017年终总结及新年计划
    Eclipse调试cas server 3.5.2.1
    CAS连接微软活动目录的配置方法
    SSO之安装CAS Server
    Tomcat之配置HTTPS
    Tomcat SSL配置 Connector attribute SSLCertificateFile must be defined when using SSL with APR解决
  • 原文地址:https://www.cnblogs.com/vagrantatbeijing/p/3402707.html
Copyright © 2011-2022 走看看