UISegmentedControl *codeButton;
codeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"My Button"]];//一个item
codeButton.frame = CGRectMake(60, 200, 200, 50);
codeButton.segmentedControlStyle = UISegmentedControlStyleBar;
codeButton.momentary = YES;
codeButton.tintColor = [UIColor redColor];
// [codeButton addTarget:self action:@selector() forControlEvents:UIControlEventValueChanged];
[view addSubview:codeButton];