NSArray *title = @[@"分组", @"全部"];UIImage *image1 = [UIImage imageNamed:@"reload_30"];UIImage *image2 = [UIImage imageNamed:@"rotate_30"];NSArray *title2 = @[image1, image2, @"文字"];UISegmentedControl *control = [[UISegmentedControl alloc] initWithItems:title2];control.selectedSegmentIndex = 1;control.frame = CGRectMake(0, 30, 300, 30);[control setTitle:@"你好" forSegmentAtIndex:0];[control setImage:image1 forSegmentAtIndex:1];[control addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];control.tintColor = [UIColor redColor];
- (void)change:(UISegmentedControl *)seg
{NSInteger index = seg.selectedSegmentIndex;if (seg.numberOfSegments == 1){[seg removeAllSegments]; }else{[seg removeSegmentAtIndex:index animated:YES];}NSLog(@"seg change...%ld", index);}