Removing empty space, if the section header is hidden in the UICollectionView

后端 未结 5 2114
無奈伤痛
無奈伤痛 2020-12-13 08:57

I have two sections in UICollectionView. I want to show a section header in UICollectionView for only 1st section. Not in 0th section.

So I

5条回答
  •  长情又很酷
    2020-12-13 09:44

    In my case I have given inset to sections so it was giving me empty space So if you have implemented following method, do it in below way

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
            if {
                return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
            }else{
                return UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
            }
        }
    

提交回复
热议问题