要现实AABBBBB的效果:
NSString *aString = @"AABBBBB"; NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:aString]; //把AA的字体颜色变为红色 [attriString addAttributes:@{NSForegroundColorAttributeName: [UIColor redColor], NSFontAttributeName: [UIFont boldSystemFontOfSize:14]} range:NSMakeRange(0, 2)]; [attriString addAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor], NSFontAttributeName: [UIFont boldSystemFontOfSize:18]} range:NSMakeRange(2, aString.length - 2)]; //显示文本 [aLable setAttributedText:attriString];