This is how you programmatically add a button like UIBarButtonItem to the center of Navigation Bar:
1 2 3 4 5 6 7 8 9 10 11 12 |
UISegmentedControl *button = [[UISegmentedControl alloc]\\ initWithItems:[NSArray arrayWithObjects:\\ LS(@"Folders"), nil]]; button.frame = CGRectMake(0, 0, 100, 30); button.center = self.view.center; button.momentary = YES; button.segmentedControlStyle = UISegmentedControlStyleBar; button.tintColor = UIColorFromRGB(0x0000DD); [button addTarget:self action:\\ @selector(foldersClicked) forControlEvents:\\ UIControlEventValueChanged]; self.navigationItem.titleView = button; |