【发布时间】:2021-11-20 07:39:01
【问题描述】:
所以我的控制器上有 UICollectionView UICollection 视图由两个部分组成。 所以当我开始滚动时,它会改变单元格大小
我的布局代码
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let section = indexPath.section
let row = indexPath.row
if section == 0 {
if (row == 0){
let width = view.frame.width
return.init(width: width, height: 120)
}else{
let width = view.frame.width
return.init(width: width, height: 50)
}
}else{
//
//return.init(width: 200, height: 120)
let width = collectionView.bounds.width / 2 - 10
return.init(width: width, height: 253)
}
}
产品在第二部分,但看起来它给出了第一部分的宽度
【问题讨论】:
标签: ios swift uicollectionview