如何在UIPageViewController SWIFT的最后一个视图上隐藏点

我希望能够隐藏UIPageViewController的最后一个视图上的分页点.有这个
question已经问过但它从来没有回答过.

如果有人能够概述一下这是如何实现的.

谢谢

编辑:

func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
        pageControl.hidden = true
        print(pageControl.hidden)//Always is false
    }

最佳答案 使用UIPageViewControllerDelegate方法:

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
    }
}

你也可以迁移到icarousel它非常强大并且很容易实现https://www.youtube.com/watch?v=OLvZbXOAZQY

点赞