Classes
The following classes are available globally.
-
CarrouselCollectionView which multiplies source to make feel it is infinitely scrolls
You can trach centered indexPath and sourceIndexPath by setting
VHCarrouselCollectionView.carrouselDelegate
– Configuration:
You should call following functions in releated delegates
1)
VHCarrouselCollectionView.scrollViewWillBeginDragging()
2)
VHCarrouselCollectionView.scrollViewWillEndDragging(...)
3)
VHCarrouselCollectionView.scrollViewDidEndScrollingAnimation()
– Usage:
Attention
You should call
scrollViewWillBeginDragging()
inUICollectionViewDelegate.scrollViewWillBeginDragging(...)
scrollViewWillEndDragging(...)
inUICollectionViewDelegate.scrollViewWillEndDragging(...)
scrollViewDidEndScrollingAnimation()
inUICollectionViewDelegate.scrollViewDidEndScrollingAnimation(...)
While using indexPath to get your related item from your source list, you should normalize it because this collectionView multiplies the indexPath.
Ex:
let source: [UIColor] = [.purple, .green] func collectionView( _ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath ) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! LocalCVC let sourceIndex = indexPath.vhCarrouselSourceIndexPath(for: collectionView).item cell.backgroundColor = source[sourceIndex] return cell }
Attention
This collectionView has some limitations:
- Only Horizontal direction supported
- Only one section supported
- Layout should be UICollectionViewFlowLayout
- All cell sizes should be same
- Supplementary elements are not supported (Ex: Header, Footer)
Declaration
Swift
open class VHCarrouselCollectionView : UICollectionView