- IRTabbedPageViewController is a powerful tab view controller for iOS.
IRTabbedPageViewController is a UIViewController that provides a simple to implement page view controller with scrolling tab bar. It also includes a UIPageViewController wrapper that provides improved data source and delegation methods.
- Git clone this project.
- Copy this project into your own project.
- Add the .xcodeproj into you project and link it as embed framework.
- You can remove the
demoandScreenShotsfolder.
- Add
pod 'IRTabbedPageViewController'in thePodfile pod install
To use the tabbed page view controller, simply create a UIViewController that is a subclass of IRTabbedPageViewController. Then implement the following data source method:
// array of view controllers to display in page view controller
- (NSArray *)viewControllersForPageViewController:(IRPageViewController *)pageViewController;If you are using a UINavigationController (As shown in Example project) you can embed the tab bar in the navigation bar. Simply set the UINavigationBar class in the navigation controller to IRTabNavigationBar and the navigation bar will attach to the view controller.
To manually attach a tab bar view to the IRTabbedPageViewController:
- Set the
tabBarViewproperty of theIRTabbedPageViewControllerto anIRTabBarViewinstance (Note:tabBarViewis weak and anIBOutlet). - Set the
dataSourceanddelegateproperties of theIRTabBarViewinstance to theIRTabbedPageViewController(Both areIBOutletable).
To customise the content of the tabs in the tab bar override the following:
- (void)tabBarView:(IRTabBarView *)tabBarView
populateTab:(IRTabBarCollectionViewCell *)tab
atIndex:(NSInteger)index;IRPageViewController is a UIViewController wrapper for UIPageViewController that provides a simpler data source and enhanced delegation methods. The data source methods are encapsulated in the IRTabbedPageViewControllerDataSource as seen above.
The delegate methods that IRPageViewControllerDelegate provides are listed below:
- (void)pageViewController:(IRPageViewController *)pageViewController
didScrollToPageOffset:(CGFloat)pageOffset
direction:(IRPageViewControllerScrollDirection)scrollDirection;Called when the page view controller is scrolled by the user to a specific offset, similar to scrollViewDidScroll. The pageOffset maintains the current page position and a scroll direction is provided.
- (void)pageViewController:(IRPageViewController *)pageViewController
didScrollToPage:(NSInteger)page;Called when the page view controller completes a full scroll to a new page.
IRTabBarView provides properties for appearance customisation, including:
sizingStyle- Whether the tab bar should size to fit or equally distribute its tabs.tabStyle- The styles to use for tabs:IRTabStyleTextfor text.IRTabStyleImagefor images.IRTabStyleImageAndTextfor images and text.IRTabStyleCustomViewfor custom view.
indicatorStyle- The style to use for the current tab indicator.indicatorAttributes- Appearance attributes for current tab indicator.tabAttributes- Appearance attributes for tabs.selectedTabAttributes- Appearance attributes for the selected tab.selectionIndicatorTransitionStyle- The transition style for the selection indicator.IRTabTransitionStyleProgressiveto progressively transition between tabs.IRTabTransitionStyleSnapto snap between tabs during transitioning.- use
setTransitionStyle:to set both theselectionIndicatorTransitionStyleandtabTransitionStyle. tabTransitionStyle- The transition style to use for the tabs.
Set custom tab view in the IRTabBarViewDataSource.
#pragma mark - IRTabBarViewDataSource
- (void)tabBarView:(IRTabBarView *)tabBarView populateTab:(IRTabBarCollectionViewCell *)tab atIndex:(NSInteger)index {
tab.customView = YOUR_CUSTOM_TAB_VIEW;
}