Open GalaxiaGuy opened 3 years ago
I can confirm it's indeed a bug. For now, I have given HoriztonalItemSpacing as 1
I looked into this, and it seems to be a know issue. It's even in the comments of the GridViewLayout (see comment here)
I tried to apply a fix, with rounding and suck but didn't work. It's a tough one to solve I guess. One of the elements needs to be a bit bigger.
A workaround (if the design lets you) can be to give the CollectionView a margin of for example 1 (for example 320 - 2 (both sides 1) divided by 3 is 106 which makes an even number.
To a bit a of detail:
I'm porting some functionality already implemented natively in Xamarin.iOS. When I asked the people who implemented the original solution how they dealt with this, they said they just put an opaque box behind the collectionview and adjusted its constraints.
It seems this is just an issue without how UICollectionViewFlowLayout
works (i.e., it is designed such that you size the cells and it fits what it can whereas the GridItemLayout assumes you tell it what should fit and it determines the size).
Fixing it completely may require creating a custom UICollectionViewLayout.
Description
A
CollectionView
using aGridItemsLayout
with aSpan
that is not a whole factor of the collection view's width, and has aHorizontalItemSpacing
of0
will still have a gap.Steps to Reproduce
CollectionView
with aGridItemsLayout
with aSpan
of 3,HoriztonalItemSpacing
of 0, and a width that is not a multiple of three (e.g full width of an iPod Touch 7th gen).CollectionView
transparent and give the cells a non-transparent background color.CollectionView
a different color to the cells.Expected Behavior
None of the content behind the
CollectionView
is visible.Actual Behavior
There is gaps between the cells in which the background content is visible.
Basic Information
Screenshots
Reproduction Link
https://github.com/GalaxiaGuy/xf-bugs/tree/bug/grid-spacing-gap