How to remove cell spacing in UICollectionView in iOS?

Total Post:17

Points:119
 1164  View(s)
Ratings:
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.

Thanks.

  1. Post:214

    Points:1642
    Re: How to remove cell spacing in UICollectionView in iOS?

    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

Answer