// 아이템 구현 예시
struct MyModel: Hashable {
let identifier = UUID()
func hash(into hasher: inout Hasher) {
hasher.combine(identifier)
}
static func == (lhs: MyModel, rhs: MyModel) -> Bool {
return lhs.identifier == rhs.identifier
}
}
코드 예시
let size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(44.0))
let item = NSCollectionLayoutItem(layoutSize: size)
let group = NsCollectionalLayoutGroup.horizontal(layoutSize: size, subItems: [Item])
let section = NSCollectionalLayoutSection(group: group)
let layout = UICollectionViewCompositionalLayout(section: section)
기존 UICollectionView
에서 Data, Presentation 구현 방법은 에러가 생길 수 있다.
UICollctionViewDataSource
UICollectionViewDiffableDataSource
기존 UICollectionView
에서 layout 구현 관련해서 복잡한 구현시, 난이도가 갑자기 올라감
UICollectionViewFlowLayout
UICollectionViewCompositionalLayout