Answers for "collectionView get current cell swift"

2

how to get current shown collectionview cell index in swift

let visibleRect = CGRect(origin: collectionView.contentOffset, size: collectionView.bounds.size)
let visiblePoint = CGPoint(x: visibleRect.midX, y: visibleRect.midY)
let visibleIndexPath = collectionView.indexPathForItem(at: visiblePoint)
Posted by: Guest on March-24-2020
1

how to get current shown collectionview cell index in swift

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
    for cell in yourCollectionView.visibleCells {
        let indexPath = yourCollectionView.indexPath(for: cell)
        print(indexPath)
    }
}
Posted by: Guest on March-24-2020

Code answers related to "collectionView get current cell swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language