Posted By

paki on 09/26/11


Tagged

UISegmentedControl


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

raulestevez
cnathan


Simple UISegmentedControl Initialization


 / Published in: Objective C
 

  1. NSArray *itemArray = [NSArray arrayWithObjects: @"Monthly", @"Yearly", @"Overview", nil];
  2. UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
  3. segmentedControl.frame = CGRectMake(40, 5, self.view.frame.size.width - 80, 30);
  4. segmentedControl.segmentedControlStyle = UISegmentedControlStyleBezeled;
  5. segmentedControl.tintColor = [UIColor blackColor];
  6. segmentedControl.selectedSegmentIndex = 0;
  7. [segmentedControl addTarget:self action:@selector(segmentedControlValueChanged:) forControlEvents:UIControlEventValueChanged];
  8. [self.view addSubview:segmentedControl];
  9. [segmentedControl release];

Report this snippet  

You need to login to post a comment.