Swift, Change width of UICollectionViewCell and UILabel(inside the cell) programmatically

左心房为你撑大大i 提交于 2019-12-03 12:57:24

It doesn't work because by the time this method is called, the collection view already knows how big the cell should be because it has got it from the flow delegate method:

optional func collectionView(_ collectionView: UICollectionView,
                  layout collectionViewLayout: UICollectionViewLayout,
             sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize

This is where you should be setting the size of your cells.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!