FGSegmentedControlViewController is a container view controller that manages view controllers through a UISegmentedControl.
@interface ExampleViewController : FGSegmentedControlViewController <FGSegmentedControlViewControllerDelegate>
// Create view controllers to switch between
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:[NSBundle mainBundle]];
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
ThirdViewController *thirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:[NSBundle mainBundle]];
// Set root view controllers
[self setViewControllers:@[firstViewController,secondViewController,thirdViewController]];
self.navigationItem.titleView = self.segmentedControl;
The segmented control can be placed in any view.
- As the titleView property of a UINavigationController
- As a UIBarButtonItem in a UIToolbar
- As subview of another view
Read the full documentation
- iOS 5.1.1
- Apple LLVM 4.0+ (ARC, auto-synthesize, literals and subscripting)
Feel free to fork and submit pull requests. This project is very early in development and I'm open to any improvements.
FGSegmentedControlViewController is available under the MIT license. See the LICENSE file for more info.