HOW TO REMOVE CELL SPACING IN UICOLLECTIONVIEW IN IOS?

Derek Honeybun

Total Post:17

Points:119
Posted by  Derek Honeybun
 746  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. Tarun Kumar

    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!