I have a UICollectionView
with 2 sections using UICollectionLayoutListConfiguration
. I want to have a Header for only one of those particular sections.
COLLECTION VIEW
lazy var collectionView: UICollectionView = {
var list = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
list.headerMode = .supplementary
let layout = UICollectionViewCompositionalLayout.list(using: list)
let view = UICollectionView(frame: .zero, collectionViewLayout: layout)
// REGISTER CELLS ETC...
return view
}()
DATASOURCE
dataSource.supplementaryViewProvider = { [weak self] collectionView, kind, indexPath in
guard let self = self else { return nil }
if let section = Section(rawValue: indexPath.section) {
switch section {
case .topSection:
// I DO NOT HAVE ANY HEADER FOR THIS SECTION
case .bottomSection:
switch kind {
case UICollectionView.elementKindSectionHeader:
// RETURN SECTION HEADER HERE
case UICollectionView.elementKindSectionFooter:
// I DO NOT HAVE ANY FOOTERS
default:
fatalError("SOMETHING BAD HAPPENED")
}
}
}
What can I try next to resolve this?