'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.stack.imgur.com/7536O.jpg
And this is what it working on vertical scroll(no spacing): https://i.stack.imgur.com/AxFMy.jpg
Following is some setting about my Collection View:
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 1:[1]
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.
Solution 2:[2]
try this :
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Abhishek Jain |
| Solution 2 | reisdev |
