Home > DeveloperSection > Forums > How to remove cell spacing in UICollectionView in iOS?
Derek Honeybun
Derek Honeybun

Total Post:17

Posted on    December-29-2015 7:31 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 327  View(s)
Rate this:

I want to remove cell spacing of UICollectionView in our application. I use many code for removing space but they are not working. Please provide me the code also.


Tarun Kumar

Total Post:210

Posted on    December-29-2015 10:49 PM

If you want to remove cell spacing in UICollectionView, then you need to set cell paddings. and collectionView provide some important methods to handle spacing are insetForSectionAtIndex: , minimumLineSpacingForSectionAtIndex: and minimumInteritemSpacingForSectionAtIndex: .
Here are the examples:

- (UIEdgeInsets)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(10, 10, 8, 8); // top, left, bottom, right

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 0.0;

Modified On Dec-29-2015 10:56:49 PM

Don't want to miss updates? Please click the below button!

Follow MindStick