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

About UICollectionViewCompositionalLayout #421

Open
crazypoo opened this issue Aug 30, 2021 · 0 comments
Open

About UICollectionViewCompositionalLayout #421

crazypoo opened this issue Aug 30, 2021 · 0 comments

Comments

@crazypoo
Copy link

Hello,I have a question.Just I use UICollectionViewCompositionalLayout,in which there are multiple items in group.How can I use this kit to slide to edit the whole group instead of a single cell?
Here is my layout code:
func layoutConfig()-> UICollectionViewCompositionalLayoutConfiguration
{
let config = UICollectionViewCompositionalLayoutConfiguration()
config.interSectionSpacing = 30
return config
}

func comboLayout()->UICollectionViewCompositionalLayout
{
    let layout = UICollectionViewCompositionalLayout.init { section, environment in
        return self.generateSection(section: section)
    }
    layout.register(DODecorationView.self, forDecorationViewOfKind: "background")
    return layout
}

func generateSection(section:NSInteger)->NSCollectionLayoutSection
{
    let sectionModel = self.listModel[section]

    var group : NSCollectionLayoutGroup
    var behavior : UICollectionLayoutSectionOrthogonalScrollingBehavior = .continuous

    var bannerItemSize = NSCollectionLayoutSize.init(widthDimension: NSCollectionLayoutDimension.fractionalWidth(1), heightDimension: NSCollectionLayoutDimension.fractionalHeight(1))
    var bannerItem = NSCollectionLayoutItem.init(layoutSize: bannerItemSize)
    
    var bannerGroupSize : NSCollectionLayoutSize
    
    bannerItem.contentInsets = NSDirectionalEdgeInsets.init(top: 0, leading: 0, bottom: 0, trailing: 0)
    bannerGroupSize = NSCollectionLayoutSize.init(widthDimension: NSCollectionLayoutDimension.absolute(kScreenWidth-20), heightDimension: NSCollectionLayoutDimension.absolute(450))
    group = NSCollectionLayoutGroup.custom(layoutSize: bannerGroupSize, itemProvider: { layoutEnvironment in
        
        var customers = [NSCollectionLayoutGroupCustomItem]()
        let itemHeader = NSCollectionLayoutGroupCustomItem.init(frame: CGRect.init(x: 0, y: 0, width: kScreenWidth-20, height: 100), zIndex: 1001)
        customers.append(itemHeader)
        
        let itemScrol = NSCollectionLayoutGroupCustomItem.init(frame: CGRect.init(x: 0, y: 100, width: kScreenWidth-100-20, height: 200), zIndex: 1002)
        customers.append(itemScrol)

        let itemInfo = NSCollectionLayoutGroupCustomItem.init(frame: CGRect.init(x: kScreenWidth-100-20, y: 100, width: 100, height: 200), zIndex: 1003)
        customers.append(itemInfo)

        let itemFooter = NSCollectionLayoutGroupCustomItem.init(frame: CGRect.init(x: 0, y: 300, width: kScreenWidth-20, height: 150), zIndex: 1004)
        customers.append(itemFooter)
        
        return customers
    })


    var sectionInsets = NSDirectionalEdgeInsets.init(top: 10, leading: 10, bottom: 10, trailing: 10)
    var laySection = NSCollectionLayoutSection(group: group)
    laySection.orthogonalScrollingBehavior = behavior
    laySection.contentInsets = sectionInsets

    return laySection
}
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

1 participant