How to set UICollectionViewCell Width and Height programmatically

后端 未结 20 1261
终归单人心
终归单人心 2020-12-04 08:06

I am trying to implement a CollectionView. When I am using Autolayout, my cells won\'t change the size, but their alignment.

Now I would rather want to

20条回答
  •  时光说笑
    2020-12-04 08:54

    An other way is to set the value directly in the flow layout

        let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout
        layout.itemSize = CGSize(width: size, height: size)
    

提交回复
热议问题