UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 300,50)];
lab.numberOfLines = 0;
lab.text = @"朦朦朧朧萌萌噠:忽地薩發羅夫的送回國的薩可減肥經典款撒積分兌換可舒服了地方上課啦放假啊大家思考理髮店說的就是咖喱驚魂甫定了件快樂的撒進防空洞酸辣粉瞭解到撒度撒化肥丹江口市啦大家看撒的環境撒發了大家看撒發的撒了咖啡店撒克拉的第撒對空射擊啊。";
lab.font = [UIFont systemFontOfSize:10];
NSRange range = [lab.text rangeOfString:@":"];
[self.view addSubview:lab];
NSMutableAttributedString *att = [[NSMutableAttributedString alloc]initWithString:lab.text];
[att addAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} range:NSMakeRange(0, range.location+1)];
lab.attributedText = att;
UILabel *lab1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 80, 300,20)];
lab1.text = @"蹦蹦跳跳正在遠離回覆星星點燈追逐:好傻啊你";
lab1.font = [UIFont systemFontOfSize:10];
[self.view addSubview:lab1];
NSRange range1 = [lab1.text rangeOfString:@"回覆"];
NSRange range2 = [lab1.text rangeOfString:@":"];
NSMutableAttributedString *att1 = [[NSMutableAttributedString alloc]initWithString:lab1.text];
[att1 addAttributes:@{NSForegroundColorAttributeName:[UIColorredColor]} range:NSMakeRange(0, range1.location)];
[att1 addAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]}range:NSMakeRange(range1.location+2, range2.location-range1.location-1)];
NSLog(@"%d %d",range1.location,range2.location);
lab1.attributedText = att1;