zepojo / UPCarouselFlowLayout

A fancy carousel flow layout for UICollectionView on iOS.
MIT License
1.66k stars 236 forks source link

How to get center index in collectionView? #55

Open reza-khalafi opened 5 years ago

reza-khalafi commented 5 years ago

Hi.
I want to get center index in this collection view at default mode or after scroll.
How to get it?

Screen Shot 2019-07-04 at 11 51 52 AM
mouness2020 commented 5 years ago
 func scrollViewDidScroll(_ scrollView: UIScrollView) {

            let centerPoint = CGPoint(x: collectionView.bounds.midX , y: collectionView.bounds.midY)

            if let indexPath = collectionView.indexPathForItem(at: centerPoint) {
//bla bla
            }
    }