[英]UICollectionview cell size
I want to be able to stretch the cell full window width, but retain the actual cell height. 我希望能够拉伸单元格的整个窗口宽度,但保留实际单元格的高度。 Is there a better way to do this then instantiating a NIB object and getting the height. 有没有更好的方法来执行此操作,然后实例化NIB对象并获取高度。 This collection will eventually consist of about 20+ different types of cell designs. 该集合最终将包含约20多种不同类型的电池设计。
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let collectionViewSize = collectionView.frame.size.width
//let sizingCell = UINib(nibName: "CustomCell", bundle: nil).instantiate(withOwner: nil, options: nil).first as! CustomCell
//return CGSize(width: collectionViewSize, height:sizingCell.frame.height)
return CGSize(width: collectionViewSize, height: 70)
}
this is titlt 这很
you must implement UICollectionViewDelegateFlowLayout 您必须实现UICollectionViewDelegateFlowLayout
and then you can edit the cell size 然后您可以编辑像元大小
ps: better use ps:更好的使用
collectionView.bounds.size.width collectionView.bounds.size.width
to get the width of collectionView 获取collectionView的宽度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.