Set insets to the CollectionView programmatically in Swift

后端 未结 1 1560
感动是毒
感动是毒 2021-01-17 09:35

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

1条回答
  •  囚心锁ツ
    2021-01-17 10:16

    Set the section inset and invalidate the layout.

    let collectionViewLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout
    
    collectionViewLayout?.sectionInset = ... // some UIEdgeInset
    
    collectionViewLayout?.invalidateLayout()
    

    0 讨论(0)
提交回复
热议问题