简体   繁体   中英

Different Cell size in a collection view in ios

i already display the image as grid view using UICollectionView with equal size like follows 在此处输入图片说明

Next step i want to display cell as different size but the images fit into the that cell like this 在此处输入图片说明 this need to be work in the storyboard because other functions done in the storyboard so somebody help me..

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:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM