0

I am using a List Compositional Layout with my UICollectionView however I can't seem to remove the Header Top Padding prior to iOS 15. Does anyone know the fallback for this, as it's giving extra padding to the top of the section header?

CODE:

func createQuickLinksLayout(with layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection {
    var configuration = UICollectionLayoutListConfiguration(appearance: .plain)
    configuration.headerMode = .supplementary
    if #available(iOS 15.0, *) {
        configuration.headerTopPadding = .zero
    } else {
        // NEED FALL BACK FOR configuration.headerTopPadding = .zero
    }
    configuration.itemSeparatorHandler = { (indexPath, sectionSeparatorConfiguration) in
        var configuration = sectionSeparatorConfiguration
        configuration.bottomSeparatorInsets = .init(top: 0, leading: 20, bottom: 0, trailing: 20)
        configuration.topSeparatorVisibility = .hidden
        return configuration
    }
    
    let section = NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
    section.decorationItems = []
    return section
}

Image with headerTopPadding = .zero

headerTopPadding = .zero

Image with default headerTopPadding

default headerTopPadding

David Henry
  • 1,972
  • 20
  • 43

0 Answers0