Challenge: Customizing the Layout | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5429927-collection-views/lessons/7

When setting the group height dimension based on the item width dimension you advised to use the .fractionalWidth(0.2) as the group height…as detail below.

let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .fractionalWidth(0.2))

But wouldn’t it be better to just reference the itemSize directly, that way any changes to the item widthDimension grid it would automatically be reflected in the group height. As detailed below in the heightDimension

let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: itemSize.widthDimension)

Seems to work nicely when I change the itemSize width.