I tried finding this question for a while but could not find this problem\'s answer.
My problem is that i have a UICollectionView
and the Scroll Direction is
SWIFT 5
For example, put this method in your ViewController with extensions UICollectionViewDelegate,UICollectionViewDataSource
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let pageWidth = scrollView.frame.size.width
let page = Int(floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1)
print("page = \(page)")
}