- (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)
}
source
share