I'm struggling to change the size of my UICollectionViewCell
programmatically.
I've tried this:
let columnLayout = FlowLayout(
itemSize: CGSize(width: 150, height: 150),
minimumInteritemSpacing: 10,
minimumLineSpacing: 10,
sectionInset: UIEdgeInsets(top: 20, left: 20, bottom: 10, right: 20))
But that doesn't work for me. Do I have to call this somewhere?
Try
self.collectionView.collectionViewLayout = columnLayout
inside viewDidLoad
lazy var columnLayout:FlowLayout = {
return FlowLayout(itemSize: CGSize(width:(self.view.frame.width - 40) / 2, height: 150),
minimumInteritemSpacing: 10,
minimumLineSpacing: 10,
sectionInset: UIEdgeInsets(top: 20, left: 20, bottom: 10, right: 20))
}()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.