简体   繁体   English

iOS集合视图中的不同单元格大小

[英]Different Cell size in a collection view in ios

i already display the image as grid view using UICollectionView with equal size like follows 我已经使用UICollectionView以相等的大小将图像显示为网格视图,如下所示 在此处输入图片说明

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: 向图像添加约束:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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