繁体   English   中英

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

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

由于内部问题已删除。

你有试过吗 用我的一个更改您的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);
}

还要使用此if条件更改cellForItemAtIndexPath if条件,以返回两个不同的单元格。 如果你有。

希望这会帮助你。

您的目标小区索引顺序次序是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);
    }

}

在故事板上,为第5,5,5,5节提供插图。 选择collectionview和in scale属性。

在此处输入图片说明

暂无
暂无

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

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