13

I have used collectionview to show models as well as years and the user can swipe the cells.

The cell which is selected would be positioned to center not depending on number of items.

Any help would be highly appreciated.

Diksha
  • 439
  • 7
  • 22

1 Answers1

22

SOL 1:

collectionView.scrollToItemAtIndexPath(indexPath, atScrollPosition: .centeredHorizontally, animated: true)

SOL 2: I suggest you add empty items at the beginning and end. So the user can scroll the first and last visible item to the centre.

Mohamed ALOUANE
  • 5,349
  • 6
  • 29
  • 60
Lumialxk
  • 6,239
  • 6
  • 24
  • 47