UICollectionViewLayout
implementation pattern.
This project is introduced in iOSDC Japan 2021.
sample code for slide
list | grid | mosaic | topAligned | detail |
---|---|---|---|---|
- only the list pattern is using iOS 14.0+ API
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]
}
Requires Xcode12 and iOS 14.0 or later.