在我UICollectionView
我使用委托方法设置不同cell
项目不同的高度:我怎样才能获得一个特定项目的高度,我UICollectionView
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
switch indexPath.item {
case 0:
return CGSize(width: view.frame.width, height: view.frame.width/2)
case 1:
return CGSize(width: view.frame.width, height: 250)
case 2:
return CGSize(width: view.frame.width, height: view.frame.width/2)
default:
return CGSize(width: view.frame.width, height: view.frame.width)
}
}
现在给出一个indexPath
,我想获得我之前分配给特定cell
项目的高度。
你想要得到的尺寸或设置大小?有问题,你问'得到'的大小在最后你写'设置'的大小 – HardikDG
@AdiHardik谢谢..你想要得到的大小 –
更新与这两种情况下,可能会有所帮助 – HardikDG