Last active
April 26, 2022 02:25
-
-
Save hlung/a23b68b5730995759a6de9b45bd877f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let layout = UICollectionViewCompositionalLayout(sectionProvider: { | |
(sectionIndex: Int, layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in | |
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .fractionalHeight(1.0)) | |
let item = NSCollectionLayoutItem(layoutSize: itemSize) | |
// (1) setting widthDimension to half of collectionView size | |
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), | |
heightDimension: .absolute(50)) | |
let group = NSCollectionLayoutGroup.horizontal( | |
layoutSize: groupSize, | |
subitem: item, | |
count: 1 | |
) | |
// (2) customize layout group here | |
section.interGroupSpacing = 16 | |
return section | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment