Created
January 19, 2019 13:57
-
-
Save laevandus/ce4cc573ee21f56769e4901fa2feb65d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
default: | |
fatalError("Unknown section \(indexPath.section).") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment