I'm using a UICollectionView with the cell width of 67, right now I am using a flow layout.
I have 3 cells in a row with 30px space between cells. How can make that distance less, so that I can fit four cells in a row? Does this method have something to do with it?
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(10, 10, 10, 10);
}
This
UICollectionViewFlowLayoutDelegate
method will help you..One more if you need more space to arrange your cells adjust the
edgeInsets
alsoNo, it doesn't. Just change the layout's
minimumInteritemSpacing
.You can use delegate method like:- for changing the space between cells in a section.
For showing top,bottom y padding between cells of different sections.
// Layout: Set Edges //setting insets for cell
You can configure spacing between cells or rows by using following properties.
1) For setting space between rows.
2) For setting space between items/cells.
You can also configure it from InterfaceBuilder(IB). Just select UICollectionView from storyboard/Xib file and click in Size Inspector as specified in below image.
swift 3.0
I had the same issue..
In my case I needed a retangular cell.
To achieve the desired result I used the UICollectionViewDelegateFlowLayout.
This is my implementation of one of the method:
This worked fine for me! I hope it helps someone.