Prabakaran
Prabakaran

Reputation: 258

Different Cell size in a collection view in ios

i already display the image as grid view using UICollectionView with equal size like follows enter image description here

Next step i want to display cell as different size but the images fit into the that cell like this enter image description here this need to be work in the storyboard because other functions done in the storyboard so somebody help me..

Upvotes: 0

Views: 1101

Answers (1)

user623396
user623396

Reputation: 1547

In your collection view controller add:

- (CGSize)collectionView:(UICollectionView *)collectionView 
                  layout:(UICollectionViewLayout*)collectionViewLayout 
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath{

   //return the size of the cell based on image size or other criteria
}

Add constraints to the image:

enter image description here

Upvotes: 1

Related Questions