Set insets to the CollectionView programmatically in Swift

后端 未结 1 1563
感动是毒
感动是毒 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)
提交回复
热议问题