Krunal Krunal - 1 year ago 98
iOS Question

Unable to adjust cell spacing in UICollectionView

I have implemented collectionView in Swift,

but the spacing between the cell increases when i check it in bigger screen iPhones.

This is the example of iphoen 5s

This is the example of iphone 6

here is my xcode design

Where i am making mistake?
can any one help me here..

Thank you in advance !

Answer Source

This solved my problem..

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
        return CGSizeMake((UIScreen.mainScreen().bounds.width-15)/2,208); //use height whatever you wants.