如何实现这种类型的集合视图网格
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);
}
同时将您的 cellForItemAtIndexPath
if 条件与此 if 条件更改为 return 两个不同的单元格。如果你有。
希望对您有所帮助。
您的目标单元格索引顺序为 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 节提供插图。 Select collectionview 和 in scale 属性。
由于内部问题已删除。
你试试这个。用我的 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);
}
同时将您的 cellForItemAtIndexPath
if 条件与此 if 条件更改为 return 两个不同的单元格。如果你有。
希望对您有所帮助。
您的目标单元格索引顺序为 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 节提供插图。 Select collectionview 和 in scale 属性。