TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Panagiotis Sartzetakis.
JRPageViewControllerKit wraps all the boilerplate code that is required for the implementation of UIPageViewController
.
This library aims to wrap all the boilerplate code that is required for the implementation of the UIPageViewController
. Within a few lines of code you have a UIPageViewController
ready to run. In order to achieve that this library overrides the UIPageViewControllerDataSource
and UIPageViewControllerDelegate
with a custom implementation. It also implements the UIScrollViewDelegate
of the scrollview that is within the UIPageViewController
.
import JRPageViewControllerKit
// 1. Create a factory that will return viewController for a specific index.
let factory: ((Int) -> ChildViewController?) = { [unowned self] index -> ChildViewController? in
let viewController = self.storyboard!.instantiateViewController(withIdentifier: "ChildViewController") as! ChildViewController
viewController.index = index
return viewController
}
// 2. Instantiate a PageViewControllerManager.
let pageViewControllerManager = PageViewControllerManager(insertIn: containerView, inViewController: self, totalPages: 6, viewControllerForIndex: factory)
// 3. Get notified when user swiped to another viewController.
pageViewControllerManager.didScrollToIndex = { index in
// The index that the user has just scrolled.
}
// 4. Get notified when another viewController is about to be appeared.
pageViewControllerManager.nextViewControllerAppears = { [unowned self] direction, ratio, destinationIndex in
let ratio = String(format: "%.2f", ratio)
let text = "direction:\(direction.rawValue), ratio:\(ratio),\n to \(destinationIndex)"
}
JRPageViewControllerKit
is being provided under MIT Licence.
Copyright © 2016-present Panagiotis Sartzetakis