我目前正在使用带有自定义xib的UICollectionView
来重新创建它
mockup
使用sizeForItemAtIndexPath
委托方法,我可以更改每个UICollectionViewCell
的尺寸:
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let screenSize = UIScreen.mainScreen().bounds
let screenWidth = screenSize.width
let screenHeight = screenSize.height
let customHeight = screenHeight / 7
if indexPath.row == 2{
return CGSizeMake(screenWidth / 3, customHeight * 2);
}
if indexPath.row == 6{
return CGSizeMake(screenWidth, customHeight * 2);
}
return CGSizeMake(screenWidth / 3, customHeight);
}
这就是我得到的:
所以我无法将前两个图像的y更改为顶部,并在底部添加两个图像(就像在样机中一样)。