UINavigationBar Cookbook and examples

Add UISegmentedControl to a navigation bar

UISegmentedControl *segmentSelector = [[UISegmentedControl alloc] initWithItems:segControlItems];
segmentSelector.segmentedControlStyle = UISegmentedControlStyleBar;
segmentSelector.momentary = YES;
[segmentSelector addTarget:self action:@selector(toolbarActionIndexChanged) forControlEvents:UIControlEventValueChanged];
[segmentSelector setWidth:40.0 forSegmentAtIndex:0];
[segmentSelector setWidth:40.0 forSegmentAtIndex:1];

UIBarButtonItem *segButton = [[UIBarButtonItem alloc] initWithCustomView:segmentSelector];
self.navigationItem.rightBarButtonItem = segButton;
[segButton release];