I’m writing a demo concerning the distinction utilizing compositional structure & conventional circulation structure with UICollectionView .
I discovered that If I wanna the cell’s width equal to the UICollectionView’s width , however the cell’s peak is decided by the cell’s content material (self-sizing solely in vertical).
- this may be simply with compositional structure
let peak = NSCollectionLayoutDimension.estimated(144)
let itemSize = NSCollectionLayoutSize(widthDimension: NSCollectionLayoutDimension.fractionalWidth(1), heightDimension: peak)
- however If I utilizing conventional circulation structure. I can solely set circulation structure’s
estimatedItemSize like this
structure.estimatedItemSize = CGSizeMake(collectionView.width, 140)
however after structure, the cell’s closing width will at all times decided by the precise content material , not the width equal to collectionView’s width.
Is there any greatest follow about this type vertical-only self-sizing?