Mimicrate to native
UIPageViewController. Each page is new controller, it can be even navigation controller. You can add any class of controllers like child. Support parent layout margins, paging and scroll by index.
You can scroll to any page programatically. If you need pages for onboarding, you can disable scroll by gester and disable swipe to dismiss.
Ready for use on iOS 12+.
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the
swift compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
Once you have your Swift package set up, adding as a dependency is as easy as adding it to the
dependencies value of your
dependencies: [ .package(url: "https://github.com/ivanvorobei/SPPageController", .upToNextMajor(from: "1.3.0")) ]
CocoaPods is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your
If you prefer not to use any of dependency managers, you can integrate manually. Put
Sources/SPPageController folder in your Xcode project. Make sure to enable
Copy items if needed and
SPPageController is container controller. Now available 2 system of paging -
.page. First using
UICollectionView like basic view, its good work with content offset but not perfect when device rotated. Second using native
UIPageViewController. You shoud choose which better for you.
Pass child controllers which using like pages and simple present page controller as you need:
// Here your controllers let controllers: [UIViewController] =  let pageController = SPPageController(childControllers: controllers, system: .page) present(pageController, animated: true, completion: nil)
You can manage layout margins of container. Apple still has bug with it, but my way support it correctly:
pageController.view.layoutMargins = .init(horizontal: 50, vertical: 0) // Don't forget enable preserve layout margins for childs: // childController.view.preservesSuperviewLayoutMargins = true
Now for all childs left and right margins will be +50pt.
If you want scroll only programatically, disable scroll between pages by gester:
pageController.allowScroll = false
For scroll by index call this function:
pageController.safeScrollTo(index: 3, animated: true)
If need disable dismiss by gester (related for modal controllers), set flag to
pageController.allowDismissWithGester = false
Видео-туториалы выклыдываю на YouTube: