如何使uicollectionview作为附加图像
问题描述:
我想使UICollectionView成为以下图像。如何使uicollectionview作为附加图像
但是,我得到以下。
我正在使用UICollectionView流布局。我用下面的代码来定义每个单元格的大小。
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
// return CGSizeMake(kScreenWidth*1.0/2 - 10, kScreenHeight*1.0/3.0 - 10);
if (indexPath.row == 0) {
return CGSizeMake(kScreenWidth*2.0/3 - 20, kScreenHeight*2.0/3.0 - 10);
} else if (indexPath.row == 1 || indexPath.row == 2 || indexPath.row == 3 || indexPath.row == 4 ||indexPath.row == 5) {
return CGSizeMake(kScreenWidth*1.0/3 - 30, kScreenHeight*1.0/3.0 - 10);
} else {
return CGSizeMake(kScreenWidth*1.0/2 - 10, kScreenHeight*1.0/3.0 - 10);
}
}
我预计单元格2将与单元格1良好对齐。但是,它流到了下一列。我怎样才能使布局成为第一个图像?
谢谢。
我已阅读源代码。看起来这比我需要的要多得多。我阅读本教程:http://skeuo.com/uicollectionview-custom-layout-tutorial,并阅读苹果的文档,https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CreatingCustomLayouts/ CreatingCustomLayouts.html。最后,我写了我的自定义集合视图布局,现在它工作。谢谢! – user890207 2014-10-23 06:54:32