We can display data in two columns in a collection view. In below code we are dividing the width of the cell into two parts of the collection view.
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake(collectionViewOutlet.frame.size.width/2-10, collectionViewOutlet.frame.size.width/2-10);
}
For this we can use the sizeForItemAtIndexPath delegate method of UICollectionView. As the name suggests this method returns the size of collection view item. In above code we are dividing the width of the cell into two parts of the collection view and as a result collection view will set two columns of items.
0 Comment(s)