Detect page change in UICollectionView

后端 未结 7 2106
醉酒成梦
醉酒成梦 2021-01-31 03:35

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

7条回答
  •  北海茫月
    2021-01-31 03:59

    Swift 3 Xcode 8.2

    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
            let x = scrollView.contentOffset.x
            let w = scrollView.bounds.size.width
            let currentPage = Int(ceil(x/w))
            // Do whatever with currentPage.
    }
    

提交回复
热议问题