What is the correct approach for Compositional Collection View Layout with autosized height?

Hello,

so I started using Compositional layout for cases where previously I would use either a Table View or Collection View with the Flow layout.

While Compositional works great for complex layout, I have a bit of an issue building simple screens. For example one header cell and then three tappable cells below it.

Code Block
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: height)
let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize)
let layoutGroup = NSCollectionLayoutGroup.vertical(layoutSize: itemSize, subitems: [layoutItem])


I am using this setup to setup the only group that gets passed to the NSCollectionLayoutSection and it works great, but I dont know what is the best way to specify height? I am using .estimated(200) for now, but this in the end (correctly) results in header that has height like 300 and then those buttons with 45 each. I just feel like I am not using the Compositional layout sizing properly.

Thanks for help.
What is the correct approach for Compositional Collection View Layout with autosized height?
 
 
Q