I want to replace a custom implementation of UICollectionViewLayout with UICollectionViewCompositionalLayout but can't seem to get the same layout. I have tried a number of combinations to generate the layout. Here's the latest.
func generateLayout() -> UICollectionViewLayout {
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/3),
heightDimension: .estimated(50))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.contentInsets = NSDirectionalEdgeInsets(top: 2, leading: 2, bottom: 2, trailing: 2)
let groupSize = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(50))
let group = NSCollectionLayoutGroup.horizontal( layoutSize: groupSize, subitems: [item])
let section = NSCollectionLayoutSection(group: group)
let layout = UICollectionViewCompositionalLayout(section: section)
return layout
}
Here's the layout produced with the code above:
All cells need to be the same size and, of course, all views should be bottom justified. The problem seems to be the height. Yes, I could use some of my code from UICollectionViewLayout to calculate the correct height but that somewhat defeats the purpose. If I have to do that I might as well keep my custom UICollectionViewLayout.
Here's what it should look like:
Is it possible to achieve my desired layout with UICollectionViewCompositionalLayout? If so, how?