改变一串字体的多个颜色

  NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"作品:%@",data[@"works_num"]]];

    NSRange redRange = NSMakeRange(0, [[noteStr string] rangeOfString:@":"].location);

    [noteStr addAttribute:NSForegroundColorAttributeName value:COLOR_9999COLOR range:redRange];

    [_productLabel setAttributedText:noteStr] ;

    [_productLabel sizeToFit];

posted on 2016-01-28 15:28  廖利君  阅读(133)  评论(0编辑  收藏  举报