附加图像的 UICollectionView 设计流程布局
UICollectionView design flow layout for attached image
我附上了我所做的和我必须达到的目标的图片。请指导我实现这一目标。
到目前为止我已经做了:
我想实现以下目标:
这是我的代码:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGSize size;
if (indexPath.row == DIGIT_INT_2 || indexPath.row == DIGIT_INT_6 || indexPath.row == DIGIT_INT_7)
size = CGSizeMake(150, 68);
else if (indexPath.row == DIGIT_INT_3 || indexPath.row == 13)
size = CGSizeMake(150, 150);
else
size = CGSizeMake(68, 68);
return size;
}
我找到了答案,我通过自定义 UICollectionViewFlowLayout class 并继承方法 - (NSArray *) layoutAttributesForElementsInRect:(CGRect)rect
并使用上一个项目框架和当前项目框架来实现它。
但是在这之后出现了一个新问题,一个项目在滚动后消失了。我找不到为什么会这样。经过两天的工作,我必须采取另一种方式来实现这一目标。
感谢 Wai Ha Lee 格式化问题。
现在这个问题解决了我的消失问题:- UICollectionView's cell disappearing
我附上了我所做的和我必须达到的目标的图片。请指导我实现这一目标。
到目前为止我已经做了:
我想实现以下目标:
这是我的代码:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGSize size;
if (indexPath.row == DIGIT_INT_2 || indexPath.row == DIGIT_INT_6 || indexPath.row == DIGIT_INT_7)
size = CGSizeMake(150, 68);
else if (indexPath.row == DIGIT_INT_3 || indexPath.row == 13)
size = CGSizeMake(150, 150);
else
size = CGSizeMake(68, 68);
return size;
}
我找到了答案,我通过自定义 UICollectionViewFlowLayout class 并继承方法 - (NSArray *) layoutAttributesForElementsInRect:(CGRect)rect
并使用上一个项目框架和当前项目框架来实现它。
但是在这之后出现了一个新问题,一个项目在滚动后消失了。我找不到为什么会这样。经过两天的工作,我必须采取另一种方式来实现这一目标。 感谢 Wai Ha Lee 格式化问题。
现在这个问题解决了我的消失问题:- UICollectionView's cell disappearing