Skip to content

Instantly share code, notes, and snippets.

@YudhistherAryan
YudhistherAryan / GetCurrentDisplayCell.swift
Last active August 1, 2021 15:01
How to get the index of visible cell in the UICollectionView
//Put this function into the extension of the UICollectionVIewDelegate and you will get the index of the current cell displaying.
// This will be helpful when you will implemenet the image slider with the help of the collectionView(by default pagination of the collectionView).
func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
print("Currently visible cell is \(self.collectionView.indexPathsForVisibleItems)")
}