NSArray *segmentedArr=[[NSArray alloc] initWithObjects:@”1”,@”2”,@”3”,@”4”, nil];
UISegmentedControl *segmented=[[UISegmentedControl alloc] initWithItems:segmentedArr];
segmented.frame=CGRectMake(100, 200, 175, 50);
[self.view addSubview:segmented];
[segmented release];
segmented.backgroundColor=[UIColor redColor];
[segmented addTarget:self action:@selector(segmentedAction:) forControlEvents:UIControlEventValueChanged];
segmented.selectedSegmentIndex=2;
segmented.tintColor=[UIColor yellowColor];
// 设置在点击后是否回复模样
segmented.momentary=YES;
// 设置指定索引的题目
[segmented setTitle:@"two" forSegmentAtIndex:1];
// 设置指定索引的图片
[segmented setImage:[UIImage imageNamed:@"check.png"] forSegmentAtIndex:3];
// 移除指定的索引的选项
[segmented removeSegmentAtIndex:0 animated:NO];