MERPageViewController
自定义水平滑动分页控制器。
这是一款自定义的横滑样式的分页控制器,能够确保 ChildViewController 的生命周期方法能正确被调用,支持动画形式的索引切换截图
支持
Swift 4.2 & iOS 9+
示例
要运行示例项目,请克隆仓库,然后首先在示例目录中运行 pod install
let pageController = MERPageViewController()
pageController.delegate = self
pageController.dataSource = self
pageController.pageBounces = false
// Automatically loads adjacent pages when you stop
// pageController.isPreloadEnabled = true
如果您需要使用可重用的 UIViewController
class AnyViewController: UIViewController, MERPageReusable { }
pageController.register(AnyViewController.self)
需要 dataSource
#pragma mark ----------------- MERPageViewControllerDataSource -----------------
func numberOfControllers(in controller: MERPageViewController) -> Int {
dataArray.count
}
func mer_pageViewController(_ controller: MERPageViewController, controllerAt index: Int) -> UIViewController {
/// If you need to use Reusable UIViewController
let child: AnyViewController = controller.dequeueReusableChild(for: index)
child.title = dataArray[index]
return child
}
安装
MERPageViewController 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到您的 Podfile 中
pod 'MERPageViewController'
作者
许可
MERPageViewController 在MIT许可下可用。有关更多信息,请参阅LICENSE文件。