4

I want to be able to hide the pagination dots on the last view of a UIPageViewController. There is this question which has already asked it but it is never answered.

If someone could just give me an overview of how this is achievable.

Thanks

EDIT:

func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
        pageControl.hidden = true
        print(pageControl.hidden)//Always is false
    }
Community
  • 1
  • 1
Henry Brown
  • 2,219
  • 8
  • 31
  • 48

1 Answers1

2

use the UIPageViewControllerDelegate method:

let pageControl = UIPageControl()

override func viewDidLoad(){
    super.viewDidLoad()
    pageControl.numberOfPages = numberOfPages()
    pageControl.currentPage = 0
    view.addSubview(pageControl)
    pageControl.currentPageIndicatorTintColor = UIColor.whiteColor()
    pageControl.pageIndicatorTintColor = UIColor.whiteColor().colorWithAlphaComponent(0.4)
}

func numberOfPages() -> Int {
    return 4 //your number of pages
}

func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
    if (index == numberOfPages()-1){
          pageControl.hidden = true
    }else{
          pageControl.hidden = false
    }
}

too you can migrate to icarousel its very powerful and easily to implement https://www.youtube.com/watch?v=OLvZbXOAZQY

Eduardo Oliveros
  • 863
  • 9
  • 20