I want to reduce the size between cells in row. Now it looks like:
I'm trying this, for reduce the size between them:
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.sectionInset = UIEdgeInsets(top: 20, left: 2, bottom: 10, right: 2) layout.minimumInteritemSpacing = 0 layout.minimumLineSpacing = 0
but it doesn't help me. What I do wrong?
Overview. A flow layout is a type of collection view layout. Items in the collection view flow from one row or column (depending on the scrolling direction) to the next, with each row containing as many cells as will fit. Cells can be the same sizes or different sizes.
A layout object determines the placement of cells, supplementary views, and decoration views inside the collection view's bounds and reports that information to the collection view. The collection view then applies the provided layout information to the corresponding views so that they can be presented onscreen.
A compositional layout is composed of one or more sections that break up the layout into distinct visual groupings. Each section is composed of groups of individual items, the smallest unit of data you want to present. A group might lay out its items in a horizontal row, a vertical column, or a custom arrangement.
For a vertically scrolling grid, this value represents the minimum spacing between items in the same row. For a horizontally scrolling grid, this value represents the minimum spacing between items in the same column.
//Objective c - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake((collectionView.frame.size.width/3)-20, 100); } // Swift 2.0 func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return CGSizeMake((collectionView.frame.size.width / 3) - 20, 100) } // Swift 3.0 override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: CGFloat((collectionView.frame.size.width / 3) - 20), height: CGFloat(100)) }
Go to the storyboard , right click on collection view and
And Check your minimum spacing between the cell and reduce it to zero .
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