Question : how to get current shown collectionview cell index in swift
Answered by : mobile-star
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)
Source : | Last Update : Tue, 31 Mar 20
Question : how to get current shown collectionview cell index in swift
Answered by : mobile-star
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { for cell in yourCollectionView.visibleCells { let indexPath = yourCollectionView.indexPath(for: cell) print(indexPath) }
}
Source : | Last Update : Tue, 31 Mar 20