【发布时间】:2018-03-23 10:03:59
【问题描述】:
如何增加单元格高度。此外,我正在增加情节提要的单元格高度,但它不起作用。 注意:(只有我想增加什么是新单元格高度)
代码:-
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if let flowLayout = collectionview.collectionViewLayout as? UICollectionViewFlowLayout {
let horizontalSpacing = flowLayout.scrollDirection == .vertical ? flowLayout.minimumInteritemSpacing : flowLayout.minimumLineSpacing
let cellWidth = (view.frame.width - max(0, numberOfCellsPerRow - 1)*horizontalSpacing)/numberOfCellsPerRow
flowLayout.itemSize = CGSize(width: cellWidth, height: cellWidth)
}
return CGSize(width: (self.view.frame.width - 8) / 3.0 , height: (self.view.frame.width - 8) / 3.0)
}
【问题讨论】:
-
确保你使用了
UICollectionViewDelegateFlowLayout这个和类名。 -
这是一个集合视图,还是三个集合视图?
-
@MilanNosáľ 在这个页面中这些有三个 collectionViews
标签: ios swift uicollectionview