Connect carousel to pageControl
Closed this issue · 1 comments
Bertges commented
Hi, I'm facing the same problem specified in this issue:
In his case, he's using another framework, but I want to keep using UPCarouselFlowLayout.
There is an easy way to get the current page?
Bertges commented
Solved my problem by getting the indexPath of the center colectionView cell.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let center = CGPoint(x: scrollView.contentOffset.x + (scrollView.frame.width / 2), y: (scrollView.frame.height / 2))
if let ip = self.collectionView!.indexPathForItem(at: center) {
self.pageControl.currentPage = ip.row
}
}