Search code examples
swiftuicollectionviewuicollectionviewlayout

Horizontal scroll UICollectionView has additional line spacing?


I'm trying to use UICollectionView to make a table, when I set it to vertical scroll, everything is working great. But when I set it to horizontal scroll, it appears some additional line spacing: https://i.sstatic.net/7536O.jpg

And this is what it working on vertical scroll(no spacing): https://i.sstatic.net/AxFMy.jpg

Following is some setting about my Collection View:

https://i.sstatic.net/aWGO3.jpg

https://i.sstatic.net/vrbLp.jpg

Is there any way to solve this? Thanks!

(Sorry for I can't post image and can't post more than 2 links, because it need more than 10 reputation..)


Solution

  • Your collection cell height is 80 and Screen height is 480 I guess, and there are 5 items showing vertically so remaining space(480-(80*5)) which is 80 is showing between items as 20 pixels. So you should either increase your cell size or adjust size of UICollecttionView.