- 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
demo
andScreenShots
folder.
- 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
tabBarView
property of theIRTabbedPageViewController
to anIRTabBarView
instance (Note:tabBarView
is weak and anIBOutlet
). - Set the
dataSource
anddelegate
properties of theIRTabBarView
instance to theIRTabbedPageViewController
(Both areIBOutlet
able).
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:IRTabStyleText
for text.IRTabStyleImage
for images.IRTabStyleImageAndText
for images and text.IRTabStyleCustomView
for 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.IRTabTransitionStyleProgressive
to progressively transition between tabs.IRTabTransitionStyleSnap
to snap between tabs during transitioning.- use
setTransitionStyle:
to set both theselectionIndicatorTransitionStyle
andtabTransitionStyle
. 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;
}