iOS中改变部分字体颜色

 NSString *secondStr = [NSString stringWithFormat:@"认识的单词共计: %ld ",(long)_yesCount];

    NSMutableAttributedString *ssa = [[NSMutableAttributedString alloc] initWithString:secondStr];

    [ssa addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(8,2)];

    _secondLabel.attributedText = ssa;

    

    

    NSString *thirdStr = [NSString stringWithFormat:@"不认识的单词共计: %ld ",(long)_noCount];

    NSMutableAttributedString *ssb = [[NSMutableAttributedString alloc] initWithString:thirdStr];

    [ssb addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(9,2)];

    _thirdLabel.attributedText = ssb;

posted @ 2016-12-20 14:22  ...A  阅读(732)  评论(0编辑  收藏  举报