collection-view-layout-pattern-sample
UICollectionViewLayout
implementation pattern.
About
This project is introduced in iOSDC Japan 2021.
sample code for slide
Pattern
list | grid | mosaic | topAligned | detail |
---|---|---|---|---|
- only the list pattern is using iOS 14.0+ API
detail patten
use DetailSectionProvider protocol
protocol DetailSectionProvider {
func layoutSection(contentWidth: CGFloat, traitCollection: UITraitCollection) -> NSCollectionLayoutSection
func provideCell(_ collectionView: UICollectionView, indexPath: IndexPath, item: DetailSectionItem) -> UICollectionViewCell
func provideHeaderView(_ collectionView: UICollectionView, indexPath: IndexPath, section: DetailSection) -> UICollectionReusableView?
func provideFooterView(_ collectionView: UICollectionView, indexPath: IndexPath, section: DetailSection) -> UICollectionReusableView?
}
struct DetailSectionModel {
var provider: DetailSectionProvider
var section: DetailSection
var items: [DetailSectionItem]
}
Requirements
Requires Xcode12 and iOS 14.0 or later.