Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the margin between two UICollectionView columns

Tags:

I have UICollectionView in which I would like to have no spacing between the cells. However despite my all effort I can't seem to remove the the space,

enter image description here

Code

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {     return 0; }  - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {     return 0; }  - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {     return UIEdgeInsetsMake(0, 0, 0, 0); } 

Extra Info

  • Cell width is 234
  • UICollectionView width is 703
like image 361
TeaCupApp Avatar asked Jan 22 '14 11:01

TeaCupApp


1 Answers

From this. You need to change minimumInteritemSpacing and minimumLineSpacing.

UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init]; flow.itemSize = CGSizeMake(cellWidth, cellHeight); flow.scrollDirection = UICollectionViewScrollDirectionHorizontal; flow.minimumInteritemSpacing = 0; flow.minimumLineSpacing = 0; mainCollectionView.collectionViewLayout = flow; 
like image 140
Hsm Avatar answered Sep 18 '22 19:09

Hsm