簡體   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