UILabel* noteLabel = [[UILabel alloc] init];
noteLabel.frame = CGRectMake(60, 100, 200, 100);
noteLabel.textColor = [UIColor blackColor];
noteLabel.numberOfLines = 2;
NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:@"点击注册按钮,即表示您已同意隐私条款和服务协议"];
NSRange redRange = NSMakeRange([[noteStr string] rangeOfString:@"注册"].location, [[noteStr string] rangeOfString:@"注册"].length);
[noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange];
NSRange redRangeTwo = NSMakeRange([[noteStr string] rangeOfString:@"同意"].location, [[noteStr string] rangeOfString:@"同意"].length);
[noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:redRangeTwo];
[noteLabel setAttributedText:noteStr];
[noteLabel sizeToFit];
[self.view addSubview:noteLabel];
NSString*string =@"sdfsfsfsAdfsdf";
string = [string substringToIndex:7];
NSLog(@"截取的值为:%@",string);
[string substringFromIndex:2];
NSLog(@"截取的值为:%@",string);
NSString*string =@"sdfsfsfsAdfsdf";
NSRangerange = [stringrangeOfString:@"f"];
NSLog(@"rang:%@",NSStringFromRange(range));
string = [string substringWithRange:range];
NSLog(@"截取的值为:%@",string);
NSString*string =@"sdfsfsfsAdfsdf";
NSArray *array = [string componentsSeparatedByString:@"A"];
NSLog(@"array:%@",array);
NSString *str1=@"1=2=3=4";
NSArray *arry=[str1 componentsSeparatedByString:@"="];
NSLog(@"%@",arry);