Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the gap between header and cell of UICollectionView?

I have a UICollectionView and it has a header and a cell. I want to remove the gap between the header and the cell.. How to do that in swift?

Here is my view...

enter image description here

I added background colour to the collectionView and header and cell also..

Please see the screenshot.

enter image description here

like image 289
Sajib Ghosh Avatar asked Nov 01 '25 17:11

Sajib Ghosh


1 Answers

Use the property section Inset of UICollectionViewFlowLayout

let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 0, left: 10, bottom: 10, right: 10)
// Here you can set according your requirement

enter image description here

For more reference: http://www.brianjcoleman.com/tutorial-collection-view-using-swift/

like image 62
UdayM Avatar answered Nov 03 '25 08:11

UdayM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!