在我的應用程序中,我使用UICollectionView獲取產品的列表。要求是有條件地設置單元高度。我使用下面的代碼。Collectionview單元格之間的最大空間
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
{
if (indexPath.row == 3 || indexPath.row == 6 || indexPath.row == 7 || indexPath.row == 10 || indexPath.row == 0)
{
return CGSizeMake((collectionView.frame.size.width/2)-4, 300.0);
}
return CGSizeMake((collectionView.frame.size.width/2)-4, 250.0);
}
通過,此代碼完全設置單元格的高度,但水平單元格未正確設置圖像。我想要刪除垂直單元格之間的額外空間。我爲單元格設置最小間距,線條從故事板邊緣起8個像素。
http://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest –
@VirajPadsala我需要Objective-C和沒有約束。 –