I am building a UICollectionView in iOS 13 using UICollectionViewCompositionalLayout with 2 sections.
I want each section to be it's own column. Is this possible with UICollectionViewCompositionalLayout?
My code:
UICollectionViewCompositionalLayout { sectionNumber, _ in
let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: .estimated(44)
))
let group = NSCollectionLayoutGroup.horizontal(
layoutSize: NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: .estimated(44)
),
subitem: item,
count: 1
)
let section = NSCollectionLayoutSection(group: group)
section.boundarySupplementaryItems = [
NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1),
heightDimension: .estimated(38)
),
elementKind: UICollectionView.elementKindSectionHeader,
alignment: .top
)
]
section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 8, trailing: 0)
return section
})
What it currently looks like:
What I want it to look like:

