Regarding to this tutorial by AppCoda about how to implement a app with UIPageViewController I\'d like to use a custom page control element on top of the pages instead of at
You have to implement a custom UIPageControl
and add it to the view. As others have mentioned, view.bringSubviewToFront(pageControl)
must be called.
I have an example of a view controller with all the code on setting up a custom UIPageControl
(in storyboard) with UIPageViewController
There are 2 methods which you need to implement to set the current page indicator.
func pageViewController(pageViewController: UIPageViewController, willTransitionToViewControllers pendingViewControllers: [UIViewController]) {
pendingIndex = pages.indexOf(pendingViewControllers.first!)
}
func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
if completed {
currentIndex = pendingIndex
if let index = currentIndex {
pageControl.currentPage = index
}
}
}