Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
return itemLayoutAttributes
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
let numberOfItems = collectionView?.numberOfItems(inSection: indexPath.section) ?? 0
guard numberOfItems > 0 else { return nil }
switch indexPath.section {
case 0:
return itemLayoutAttributes[indexPath.item]
fatalError("Unknown section \(indexPath.section).")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment