Search code examples
iosswiftscrollcollectionview

How can I set custom horizontal scroll for Collection View in Swift, XCode?


I want to set custom horizontal scroll for my CollectionView, that it will be scrolling by 1 cell (not by the whole width of my screen).

I could set HORIZONTAL scroll, but not custom. (See screens). 1 screen: my extension of my collectionView for UIScrollViewDelegate. *I saw, that in console (see too) "x" - my offset = 290 - it's true! But on fact it is not 290. Paging was marked in "true" 2 screen: delegate and dataSource.

enter image description here

Help, please!


Solution

  • You could create a custom UICollectionViewFlowLayout that will center the cells in the screen and then page one at a time. Karmadust have written a good blog post that I have successfully used in the past to do the same thing

    http://blog.karmadust.com/centered-paging-with-preview-cells-on-uicollectionview/