Thursday, May 22, 2025
HomeiOS Developmentios - Heart alignment in a single NSCollectionLayoutSection

ios – Heart alignment in a single NSCollectionLayoutSection

[ad_1]

I am curious to know, can I obtain this alignment in just one NSCollectionLayoutSection.

Picture

My code for the part is:

non-public func createHeaderTagsSection(utilizing part: Part) -> NSCollectionLayoutSection {
        let itemSize = NSCollectionLayoutSize(widthDimension: .estimated(100), heightDimension: .absolute(Margins.edgeDouble))
        let merchandise = NSCollectionLayoutItem(layoutSize: itemSize)
        
        let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: itemSize.heightDimension)
        let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item])
        group.interItemSpacing = .fastened(Margins.spacingHalf)
        
        let part = NSCollectionLayoutSection(group: group)
        part.contentInsets = .init(prime: 0, main: Margins.edgeDefault, backside: Margins.edgeDefault, trailing: DS.Margin.edgeDefault)
        part.interGroupSpacing = 8
        
        let sectionBackground = NSCollectionLayoutDecorationItem.background(elementKind: SectionBackgroundDecorationView.identifier)
        part.decorationItems = [sectionBackground]
        
        return part
    }

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments