I am using UICollectionView
first time in my iPad application.
I have set UICollectionView
such that its size and cell size is same, means only onc
var visibleCurrentCellIndexPath: IndexPath? {
for cell in self.collectionView.visibleCells {
let indexPath = self.collectionView.indexPath(for: cell)
return indexPath
}
return nil
}
As an Extension:
extension UICollectionView {
var visibleCurrentCellIndexPath: IndexPath? {
for cell in self.visibleCells {
let indexPath = self.indexPath(for: cell)
return indexPath
}
return nil
}
}
Usage:
if let indexPath = collectionView.visibleCurrentCellIndexPath {
/// do something
}