Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView - distance between cells?

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);  } 
like image 726
Sarabyte Studios Avatar asked Mar 20 '13 03:03

Sarabyte Studios


People also ask

How do I change the spacing between cells in collection view?

I have found very easy way to configure spacing between cells or rows by using IB. Just select UICollectionView from storyboard/Xib file and click in Size Inspector as specified in below image. For configuring space programatically use following properties. 1) For setting space between rows.

What is UICollectionView flow layout?

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.

What is Minimuminteritemspacing in Swift?

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.

What is UICollectionViewCompositionalLayout?

UICollectionViewCompositionalLayout. A layout object that lets you combine items in highly adaptive and flexible visual arrangements.


1 Answers

This UICollectionViewFlowLayoutDelegate method will help you..

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionView *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section     {     return 10; // This is the minimum inter item spacing, can be more   } 

One more if you need more space to arrange your cells adjust the edgeInsets also

like image 50
Anil Varghese Avatar answered Sep 20 '22 19:09

Anil Varghese