Skip to content

Instantly share code, notes, and snippets.

@matrixfox
Last active August 29, 2015 14:10
Show Gist options
  • Save matrixfox/8fd74338c7529d516692 to your computer and use it in GitHub Desktop.
Save matrixfox/8fd74338c7529d516692 to your computer and use it in GitHub Desktop.
- (void)viewDidLoad
{
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObjects:
@"Segm 1",
@"Segm 2",
@"Segm 3",
@"Segm 4", nil]];
[segmentedControl setFrame:CGRectMake(20, 20, [UIScreen mainScreen].bounds.size.width - 40, 30)];
[segmentedControl setSelectedSegmentIndex:0];
[segmentedControl setTintColor:[UIColor greenColor]];
[self.view addSubview:segmentedControl];
if(segmentedControl.selectedSegmentIndex == 0){
NSLog(@"Red");
} else if (segmentedControl.selectedSegmentIndex == 1) {
NSLog(@"Blue");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment