private func listLayout() -> UICollectionViewCompositionalLayout {
let itemSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .estimated(80))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .estimated(80))
let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitems: [item])
group.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: nil, top: .fixed(3), trailing: nil, bottom: nil)
let section = NSCollectionLayoutSection(group: group)
section.contentInsets = NSDirectionalEdgeInsets(top: 3, leading: 0, bottom: 0, trailing: 0)
let headerSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .estimated(80))
let headerSupplementary = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: headerSize,
elementKind: ElementKind.sectionHeader,
alignment: .top)
headerSupplementary.pinToVisibleBounds = true
section.boundarySupplementaryItems = [headerSupplementary]
return UICollectionViewCompositionalLayout(section: section)
}
private func listLayout() -> UICollectionViewCompositionalLayout {
let layout = UICollectionViewCompositionalLayout { _, layoutEnvironment in
var configuration = UICollectionLayoutListConfiguration(appearance: .grouped)
configuration.headerMode = .supplementary
configuration.backgroundColor = .systemGray6
let section = NSCollectionLayoutSection.list(using: configuration, layoutEnvironment: layoutEnvironment)
section.contentInsets = NSDirectionalEdgeInsets(top: 7, leading: 0, bottom: 0, trailing: 0)
section.interGroupSpacing = 7
let headerSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .estimated(80))
let headerSupplementary = NSCollectionLayoutBoundarySupplementaryItem(
layoutSize: headerSize,
elementKind: ElementKind.sectionHeader,
alignment: .top)
headerSupplementary.pinToVisibleBounds = true
headerSupplementary.zIndex = 110
section.boundarySupplementaryItems = [headerSupplementary]
return section
}
return layout
}
https://nemecek.be/blog/83/how-to-create-sticky-headers-with-compositional-layout
https://techblog.gccompany.co.kr/compositional-layoutκ³Ό-diffable-datasourceλ‘-ν-리ν©ν λ§νκΈ°-d80ac0d11edd
https://velog.io/@hyesuuou/iOSSwift-UICollectionLayoutListConfiguration.plainμ-ν€λλ₯Ό-λ£μμ-λ-ν€λμμ-λκ°-μ¬λ°±μ΄-μκΈ°λ-κ²½μ°
https://medium.com/@pruthvi187/uicollectionview-list-layout-beb22f5a7021
https://developer.apple.com/documentation/uikit/uicollectionviewcompositionallayoutsectionprovider
https://developer.apple.com/documentation/uikit/uicollectionlayoutlistconfiguration
https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/implementing_modern_collection_views#4208526