chang color of some characters in a string

 //先把这个string取出来,转化一下属性

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:_interstnumLabel.text];

//建立字典

 NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:[UIColor yellowColor],NSForegroundColorAttributeName, nil];

//调用改变属性方法

 [str setAttributes:dict range:NSMakeRange(0, 2)];

//重新赋给源本

 _interstnumLabel.attributedText = str;

你可能感兴趣的:(iOS)