iosswiftuicollectionviewuiedgeinsets

UICollectionView - add bottom inset for entire collectionView


I have a UICollectionView with multiple sections.

I would like to add bottom inset to the entire collectionView.

All the Q&As suggest to use the following function:

func collectionView(_ collectionView: UICollectionView, 
                  layout collectionViewLayout: UICollectionViewLayout, 
       insetForSectionAt section: Int) -> UIEdgeInsets

But this adds insets to all the sections. Where I need space only it the bottom of the collectionView


Solution

  • You can try

    collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom:<#someValue#>, right: 0)