Easy UICollectionView Custom Layout



我想创建一个自定义布局,它应该看起来像这里的图片:自定义布局

我找到了 Ray Wenderlich (https://www.raywenderlich.com/107439/uicollectionview-custom-layout-tutorial-pinterest) 的教程,它或多或少做了同样的事情,但这对我来说很复杂,所以我无法将其转移到我的需求。

只需要简单的布局,而且我也知道我的单元格的大小,我不必计算它们。谁能帮帮我。

in

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

UICollectionViewDataSource为变量indexPath.row创建switch并设置单元格的大小:

cell.frame = CGMake(height: myHeight; width: myWidth)

最新更新