Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Space between Collection View Cell in ios in Iphone 6 and iPhone 6plus?

i have simple CollectionView but it works well in iphone 4 and 5 and 5s. but when i run in to iphone 6 and 6plus it look like

enter image description here

but i want to remove space between cell in iphone 6 and 6 plus . is it property for remove space ?? if is it property pls tell me.

like image 423
princ___y Avatar asked Dec 18 '22 21:12

princ___y


1 Answers

- (CGSize)collectionView:(UICollectionView *)collectionView
                  layout:(UICollectionViewLayout *)collectionViewLayout
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    float width = collectionView.frame.size.width / 2;
    return CGSizeMake(width, width);

}

for Swift

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
{
    return CGSizeMake(collectionView.frame.size.width/2, collectionView.frame.size.width/2)
}
like image 109
Rahul Patel Avatar answered Dec 21 '22 10:12

Rahul Patel