Pager library is the easiest way of setting up a Pager. It comes with some convenience methods like, disabling swipe, and navigating backwards and forwards. Pager handles the menu navigation to navigate to a specific page.
- iOS 10.0+
- Xcode 9
Just add the Source folder to your project.
or use CocoaPods with Podfile:
pod 'Pager'
- Create a your Model object inheriting from:
Ìtem
like this:
class Model: Item {
let image: String
init(title: String, description: String, imageName: String) {
self.image = imageName
super.init(title: title, description: description)
}
}
- Create your detail view controller and conform to
ItemPresentable
like this:
extension PageDetailViewController: ItemPresentable {
func configuredWith(item: Item) -> UIViewController {
guard let model = item as? Model else {
descriptionText = item.description
return self
}
titleText = model.title
descriptionText = model.description
imageName = model.image
return self
}
}
- Create PagerContainerViewController and configure:
let controller = Pager.PageContainerViewController.instantiate()
present(controller, animated: true)
let controllers = dataSource.map { _ in PageDetailViewController.instantiate() ?? PageDetailViewController() }
controller.configure(with: dataSource, controllers: controllers)
Pager is released under the MIT license.
If you use the open-source library in your project, please make sure to credit.