kishikawakatsumi/IBPCollectionViewCompositionalLayout

interItemSpacing issue for nested group

iAllenC opened this issue · 1 comments

when i setted interItemSpacing for a vertical group which cotnains two or more horizontal groups, the interItemSpacing for the vertical group is ignored if run on iOS 12 or earlier, but it behaviors fine on iOS 13 or later.To reproduce this issue, just replace the function createLayout of TwoColumnViewController with codes below:

`
func createLayout() -> UICollectionViewLayout {
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .fractionalHeight(1.0))
let item = NSCollectionLayoutItem(layoutSize: itemSize)

    let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
                                          heightDimension: .absolute(44))
    let group1 = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 2)
    group1.interItemSpacing = .fixed(10)
    let group2 = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 2)
    group2.interItemSpacing = .fixed(10)
    let group = NSCollectionLayoutGroup.vertical(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .absolute(44+10+44)), subitems: [group1, group2])
    let spacing = CGFloat(10)
    group.interItemSpacing = .fixed(spacing)

    let section = NSCollectionLayoutSection(group: group)
    section.interGroupSpacing = 20
    section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10)

    let layout = UICollectionViewCompositionalLayout(section: section)
    return layout
}

`
Hope you can reply me !

@iAllenC Just fyi, this library provides a limited amount of support for the compositional layout pre iOS 13. iOS 13 and onward it just delegates to the builtin UIKit class