最佳答案
在创建 Collection View 布局时添加这些行
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 20, left: 0, bottom: 10, right: 0)
layout.itemSize = CGSize(width: screenWidth/2, height: screenWidth/2)
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
collectionView!.collectionViewLayout = layout
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
if indexPath.row == 0
{
return CGSize(width: screenWidth, height: screenWidth/2)
}
return CGSize(width: screenWidth/2, height: screenWidth/2);
}
关于ios - 如何减少 collectionview 中两个单元格之间的垂直空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47709215/