First of all, segmented control in iOS belongs to the UISegmentedControl class, and not to NS ...
To create it with any number of segments you want, you can use the initWithItems:
initialize method - pass an array of titles (NSStrings) or images for each segment. eg:.
UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"1", @"2", @"3", @"4", nil]];
You can change your control insertSegmentWithImage:atIndex:animated:
using the insertSegmentWithImage:atIndex:animated:
insertSegmentWithTitle:atIndex:animated:
or / and removeSegmentAtIndex:animated:
.
You can find descriptions of these (and some more!) Methods in apple docs .
source share