NSString *str1 = @"1111";
NSString *str2 = @"2222";
[self customizeStr:str1 colorStr:str2];
}
- (void)customizeStr:(NSString *)str colorStr:(NSString *)colorStr
{
NSString *apendStr = [NSString stringWithFormat:@"%@%@",str,colorStr];
NSMutableAttributedString *customizeStr = [[NSMutableAttributedString alloc]initWithString:apendStr];
NSDictionary *atr = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor greenColor]};
NSRange colorStrRan = NSMakeRange(2, 4);
[customizeStr setAttributes:atr range:colorStrRan];
_colorLabel.attributedText = customizeStr;
}
网友评论