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;

原文地址:https://www.cnblogs.com/candyMan1001/p/6202504.html