how to get indexPath for cell which is located in the center of UICollectionView

前端 未结 11 2282
慢半拍i
慢半拍i 2020-12-25 09:41

How can i find indexPath for cell in the middle of UICollectionView?

I have horizontal scrolling and only one big cell<

11条回答
  •  忘掉有多难
    2020-12-25 10:17

    Swift 4

    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        let indexPath = collectionView.indexPathForItem(at: collectionView.bounds.center)        
    }
    

提交回复
热议问题