简体   繁体   English

如何实现这种类型的集合视图网格

[英]How to achieve this type of collection view grid

由于内部问题已删除。

Have you try this. 你有试过吗 Change your sizeForItemAtIndexPath function with my one. 用我的一个更改您的sizeForItemAtIndexPath函数。

- (CGSize)collectionView:(UICollectionView *)collectionView
          layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row%3==0) {
        return CGSizeMake(self.collectionView.frame.size.width, 80);
    }
    CGFloat minSpace = 10; //Set this minSpace for space that you want between two cell
    return CGSizeMake((self.collectionView.frame.size.width - minSpace)/2, 80);
}

Also change your cellForItemAtIndexPath if condition with this if condition to return two different cell. 还要使用此if条件更改cellForItemAtIndexPath if条件,以返回两个不同的单元格。 If you have. 如果你有。

Hope this will help you. 希望这会帮助你。

Your target cell index order order are 0 , 1,2 , 3 , 4,5 6 , 7,8 9 ,...... Your order for identification is 0,3,6,9... code for size for item at indexpath should be 您的目标小区索引顺序次序是0,1,2,3,4,5- 6,7,8 9,......你的识别顺序是0,3,6,9 ...为大小代码indexpath中的项目应为

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


    NSUInteger pos = indexPath.row;
    if(pos%3==0)
    {
        return CGSizeMake(dynamicCollection.frame.size.width-10, 80);

    }
    else
    {
       return CGSizeMake(dynamicCollection.frame.size.width/2-10, 80);
    }

}

In your story board provide inset for sections 5,5,5,5 . 在故事板上,为第5,5,5,5节提供插图。 Select the collectionview and in scale attribute. 选择collectionview和in scale属性。

在此处输入图片说明

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

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