Currently, I am using UICollectionViewCompositionalLayout to achieve the following list layout with spacing:
We were thinking of trying out UICollectionLayoutListConfiguration
due to its ability to support swipe actions.
We would like to specify the spacing between each item. However, I do not find a way to specify item spacing in UICollectionLayoutListConfiguration
.
Does UICollectionLayoutListConfiguration
not support item spacing, or have I missed something?
Thanks.
Create your compositional layout using the section provider initializer, and then set the interGroupSpacing
(documentation) of the NSCollectionLayoutSection
to a larger value, such as 10
in this example:
UICollectionViewCompositionalLayout { section, layoutEnvironment in let config = UICollectionLayoutListConfiguration(appearance: .insetGrouped) let layoutSection = NSCollectionLayoutSection.list(using: config, layoutEnvironment: layoutEnvironment) layoutSection.interGroupSpacing = 10 return layoutSection }