Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interItemSpacing issue for nested group #163

Open
iAllenC opened this issue Jun 14, 2023 · 1 comment
Open

interItemSpacing issue for nested group #163

iAllenC opened this issue Jun 14, 2023 · 1 comment

Comments

@iAllenC
Copy link

iAllenC commented Jun 14, 2023

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 !

@mgray88
Copy link

mgray88 commented Jun 15, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants