NSArray * segMArr = [NSArray arrayWithObjects:@"0",@"1", nil];

UISegmentedControl * segmentC = [[UISegmentedControl alloc]initWithItems:segMArr];

    segmentC.frame = CGRectMake(0, 178, 320, 30);

    segmentC.segmentedControlStyle = UISegmentedControlStylePlain;

    segmentC.tintColor = [UIColor BlueColor];

    segmentC.selectedSegmentIndex = 0;

    [segmentC addTarget:self action:@selector(segmentedControlSelected:) forControlEvents:UIControlEventValueChanged];

    [bgView addSubview:segmentC];

  • (void)segmentedControlSelected:(UISegmentedControl*)seg{

    if (seg.selectedSegmentIndex == 0) {

        

    }else if (seg.selectedSegmentIndex == 1){

    

    }

}