我已经为集合视图创建了页面控件,每个集合视图单元格都是屏幕的高度和宽度。这是页面控件的设置:
// Setup the page control
func setupPageControl() {
pageControl.pageIndicatorTintColor = cellColor
pageControl.currentPageIndicatorTintColor = themeColor
view.addSubview(pageControl)
addPageControlConstraints()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
pageControl.numberOfPages = collectionViewCellData.count
return collectionViewCellData.count
}
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
pageControl.currentPage = indexPath.row
}
页面控件有一个小问题,请检查一下:
注意,当我什至还没有完全转到下一页时,页面控件将如何更改,如何解决此问题?
您需要使用UIPageViewControllerDelegate的方法“ didFinishAnimating:previousViewControllers:transitionCompleted:”,并使用transitionCompleted布尔值来帮助您更新页面]]