If you use Interface Builder, you can change the number of segments by 3, and then double-click on each segment to change the value.
When adding code, you can use the following:
UISegmentedControl *myControl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(170, 5, 125, 35)]; [myControl insertSegmentWithTitle: @"Easy" atIndex: 0 animated: NO ]; [myControl insertSegmentWithTitle: @"Hard" atIndex: 1 animated: NO ]; myControl.selectedSegmentIndex = 0; [myControl addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventValueChanged];
source share