尝试创建自定义单元格,但是当我在单元格collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath)
中添加标签时不起作用。
没有标签单元界面:
iPad模拟器用户界面为:
但是当我在单元格中添加标签时:
iPad Simulator用户界面变为:
在UICollectionViewDelegateFlowLayout
方法中:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let emptySpace = 87*2 + 10
let remainingWidth = Int(self.view.frame.width) - emptySpace
return CGSize(width: remainingWidth/2, height: remainingWidth/2)
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句