指定一行中文本不同颜色

UILabel *attrLabel;

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"258MB"];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(0,5)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:30.0] range:NSMakeRange(0, 3)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:30.0] range:NSMakeRange(4, 5)];

attrLabel.attributedText = str;



你可能感兴趣的:(文本,uilabel,IOS初级开发)