priya sharma priya sharma - 8 months ago 25
Objective-C Question

cell spacing in custom view cell

I am newbie in iOS developing field. And i am facing trouble in creating custom cell. I have even tried changing Min spacing in size inspector from 10 to 2. But nothing is working out. Can anybody help me out.

enter image description here

And here is the attribute set for the custom cell. attribute given for the custom cell


Change your code like this in the sizeForItemAtIndexPath method

-(CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
    CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
    CGFloat minSpace = 10; //Space that you want
    return  CGSizeMake((screeWidth - minSpace) / 2 , cellHeight); //Cell height is your collectionViewCell height.

Hope this will help you.