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

  • 相关阅读:
    x01.JavaHello
    x01.Weiqi.1 提子算法
    x01.Weiqi.3 网络对弈
    Cryptography
    Javascript判断中文字节
    asp.net mvc,asp.net4.0空间出售
    Sql Server中判断日志是否为一个星期
    DIV+CSS实现二级导航菜单
    ExecutorService线程池 [转]
    Android程序开发所用app图标的几种大小
  • 原文地址:https://www.cnblogs.com/vagrantatbeijing/p/3402707.html
Copyright © 2011-2022 走看看