I have overloaded the UICollectionViewFlowLayout to have a single horizontal row slider containing UIImages in each UICollectionViewCell.
In the overloaded UICollectionViewFlowLayout, I have set the minimumLineSpacing to 0 to get no spacing between UICollectionViewCells. (default is 10px)
In case each cell has the same width, the 0px spacing is correctly displayed
In case a cell has a bigger width, the 0px are no more taken into account and the default 10px between cells is applied..
I have tried to implement the following method but same result...
- (CGFloat)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
minimumLineSpacingForSectionAtIndex:(NSInteger)section {
return 0.0;
}
UICollectionViewCells with different width ?Is it a bug? No
This is not a bug, it is the default behavior of the UICollectionViewFlowLayout. Flow layout is a line breaking layout that means assume that it will place all your cells along a straight line and going to arrange it on the screen. Once it fill a row(no space for a new item), it will break the line and go for the next. UICollectionViewFlowLayout assures minimumLineSpacing no the exact. If your item sizes are different flow layout arranges the cells in such a way that to keep the minimum line spacing. So line size may increase but never be a lower value than you set previously.

I dont think it is possible with flow layout, you should use one custom layout. Check this iam not sure that you can set the spacing to zero give a try
JSPrintDemo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With