Member-only story
Can you use Swift to replace a UIPageView with a UICollectionView?
2 min readJun 12, 2019
Can we create our own implementation of a UIPageController rather than just simply implementing a UICollectionViewController? You bet we can!
Prerequisites:
- It would be beneficial to already have experience of using a UIPageController
Terminology
- UIPageViewController: A container view controller often used for tutorial landing pages or feature lists. Most Apps use it.
- UICollectionView: An object that manages an ordered collection of data items presented in a customizable layouts.
The problem (opportunity)
Instead of just using a UIPageController we can implement a UICollectionView. We need to make sure that the width of each cell is less than the screen width.
The difficulties — Paging
We will also need to make sure that we have paging disabled as we are not letting our UICollectionView clip to the normal upper-left hand corner of the view, but it’s center. To enable this we override scrollViewWillEndDragging;