[英]UICollectionView with different cell size
My goal is to create a UICollectionView
with a layout as depicted below.我的目标是创建一个UICollectionView
,其布局如下所示。
Is this possible without creating a custom UICollectionViewLayout
?这可能不创建自定义UICollectionViewLayout
吗?
Use UICollectionViewDelegateFlowLayout method.使用 UICollectionViewDelegateFlowLayout 方法。
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let width : CGFloat
let height : CGFloat
if indexPath.item == 0 {
width = 100
height = 100
} else {
width = 50
height = 50
}
return CGSizeMake(width, height)
}
Without creating a custom layout of collection view it is not possible to achieve what you want.如果不创建集合视图的自定义布局,就不可能实现您想要的。
You can create custom cell size using its delegate method sizeforitematindexpath
.您可以使用其委托方法sizeforitematindexpath
创建自定义单元格大小。
Also, check this link which helps to create a custom layout.此外,请检查此链接,这有助于创建自定义布局。
many ways to do this below links.很多方法可以在下面的链接中做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.