This control combines the great menu view with a UIPageviewController that takes care of showing the right page when clicking on the menu view and updating the selection when the UIPageviewController scrolls.
Install with Cocoapods by adding the following to your Podfile:
platform :ios, '9.0'
pod 'HQPagerViewController', :git=> 'https://github.com/quangpc/HQPagerViewController.git', :branch=> 'master'
Copy HQPagerViewController.swift & HQPagerMenuView.swift to your project.
Basically we just need to provide the list of child view controllers to show and these view controllers should provide the information for conform HQPagerViewControllerDataSource. Check sample project to see how it works.
We strongly recommend to use IB to set up our page controller views.
Drag into the storyboard a UIViewController and set up its class with your pager controller (HQPagerViewController). Drag a UIView into your view controller view and connect to containerView outlet. Drag a UIView into your view controller view and set class to HQPagerMenuView then connect to outlet menuView
Provide HQPagerMenuViewItemProvider for each child controller
extension SampleViewController: HQPagerViewControllerDataSource {
func menuViewItemOf(inPager pagerViewController: HQPagerViewController) -> HQPagerMenuViewItemProvider {
let item = HQPagerMenuViewItemProvider(title: titles[index], normalImage: normalIcons[index], selectedImage: highlightedIcons[index], selectedBackgroundColor: colors[index])
return item
}
}
menuView.titleFont = UIFont.boldSystemFont(ofSize: 14)
menuView.titleTextColor = UIColor.black
setSelectedIndex(index: 1, animated: false)
iOS 9 and above
...are really welcome. If you have an idea just fork the library change it and if its useful for others and not affecting the functionality of the library for other users I'll insert it
MIT License