Set insets to the CollectionView programmatically

2019-06-15 18:06发布

I have ViewController with the CollectionView in it. I want to change CollectionView insets by pressing button. What code I should implement?

Thank you!

1条回答
闹够了就滚
2楼-- · 2019-06-15 18:46

Set the section inset and invalidate the layout.

let collectionViewLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout

collectionViewLayout?.sectionInset = ... // some UIEdgeInset

collectionViewLayout?.invalidateLayout()
查看更多
登录 后发表回答