Skip to content

Instantly share code, notes, and snippets.

@sumardi
Created October 22, 2011 17:39
Show Gist options
  • Select an option

  • Save sumardi/1306262 to your computer and use it in GitHub Desktop.

Select an option

Save sumardi/1306262 to your computer and use it in GitHub Desktop.
iPhoneDev - Multiple buttons on navigation bar.
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray array]];
[segmentedControl setMomentary:YES];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"191-Up.png"] atIndex:0 animated:NO];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"191-Down.png"] atIndex:1 animated:NO];
segmentedControl.autoresizingMask = UIViewAutoresizingNone;
segmentedControl.frame = CGRectMake(0.0f, 0.0f, 90.0f, 30.0f);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[segmentedControl addTarget:self action:@selector(pagingAction:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
self.navigationItem.rightBarButtonItem = segmentBarItem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment