MSSTabbedPageViewController is now deprecated, and a new Swift component is available in the form of Tabman. Unfortunately this can't be made compatible with Objective-C.
A seperate component, Pageboy is available to provide the UIPageViewController enhancements present in MSSTabbedPageViewController and much more.
MSSTabbedPageViewController 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.
To run the example project, clone the repo and build the project. Examples are available for both Objective-C and Swift projects.
MSSTabbedPageViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MSSTabbedPageViewController'
And run pod install.
To use the tabbed page view controller, simply create a UIViewController that is a subclass of MSSTabbedPageViewController. Then implement the following data source method:
// array of view controllers to display in page view controller
- (NSArray *)viewControllersForPageViewController:(MSSPageViewController *)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 MSSTabNavigationBar and the navigation bar will attach to the view controller.
To manually attach a tab bar view to the MSSTabbedPageViewController:
- Set the
tabBarViewproperty of theMSSTabbedPageViewControllerto anMSSTabBarViewinstance (Note:tabBarViewis weak and anIBOutlet). - Set the
dataSourceanddelegateproperties of theMSSTabBarViewinstance to theMSSTabbedPageViewController(Both areIBOutletable).
To customise the content of the tabs in the tab bar override the following:
- (void)tabBarView:(MSSTabBarView *)tabBarView
populateTab:(MSSTabBarCollectionViewCell *)tab
atIndex:(NSInteger)index;
MSSPageViewController is a UIViewController wrapper for UIPageViewController that provides a simpler data source and enhanced delegation methods. The data source methods are encapsulated in the MSSTabbedPageViewControllerDataSource as seen above.
The delegate methods that MSSPageViewControllerDelegate provides are listed below:
- (void)pageViewController:(MSSPageViewController *)pageViewController
didScrollToPageOffset:(CGFloat)pageOffset
direction:(MSSPageViewControllerScrollDirection)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:(MSSPageViewController *)pageViewController
didScrollToPage:(NSInteger)page;
Called when the page view controller completes a full scroll to a new page.
MSSTabBarView provides properties for appearance customisation, including:
sizingStyle- Whether the tab bar should size to fit or equally distribute its tabs.tabStyle- The style to use for tabs, eitherMSSTabStyleTextfor text orMSSTabStyleImagefor images.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.MSSTabTransitionStyleProgressiveto progressively transition between tabs.MSSTabTransitionStyleSnapto snap between tabs during transitioning.- use
setTransitionStyle:to set both theselectionIndicatorTransitionStyleandtabTransitionStyle. tabTransitionStyle- The transition style to use for the tabs.
Supports iOS 8 and above.
Merrick Sapsford
Mail: [email protected]
