Simple UISegmentedControl Initialization


/ Published in: Objective C



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.