3

我可以UICollectionViewCompositionalLayout用来创建类似 Pinterest / Waterflow 的布局吗?

关闭是与

func buildLayout() -> UICollectionViewCompositionalLayout {

    // cells
    let itemSize = NSCollectionLayoutSize(widthDimension: .estimated(10), heightDimension: .estimated(10))
    let item = NSCollectionLayoutItem(layoutSize: itemSize)

    let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(10))
    let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 3)
    group.interItemSpacing = .flexible(10)

    let section = NSCollectionLayoutSection(group: group)
    section.interGroupSpacing = 10

    let configuration = UICollectionViewCompositionalLayoutConfiguration()
    configuration.scrollDirection = .vertical
    return UICollectionViewCompositionalLayout(section: section, configuration: configuration)

}

但我不知道如何删除每个项目下的空间在此处输入图像描述

4

0 回答 0