Created
April 1, 2022 08:30
-
-
Save KrauserHuang/0cfa15a8d993404154c7ec29afa6de84 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
func generateLayout() -> UICollectionViewLayout { | |
let itemSize = NSCollectionLayoutSize( | |
widthDimension = .fractionalWidth(1.0), | |
heightDimension = .fractionalHeight(1.0)) | |
let fullPhotoItem = NSCollectionLayoutItem(layoutSize: itemSize) | |
fullPhotoItem.contentInsets = NSDirectionalEdgeInsets(top: 2, leading: 2, bottom: 2, trailing: 2) | |
let groupSize = NSCollectionLayoutSize( | |
widthDimension = .fractionalWidth(1.0), | |
heightDimension = .fractionalWidth(1/3)) | |
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, | |
subitem: fullPhotoItem, | |
count: 2) | |
let section = NSCollectionLayoutSection(group: group) | |
let layout = UICollectionViewCompositionalLayout(section: section) | |
return layout | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment