Skip to content

Instantly share code, notes, and snippets.

@ShoMasegi
Last active March 30, 2019 09:44
Show Gist options
  • Save ShoMasegi/1321357a8ae685f2b58f7006fb35deaf to your computer and use it in GitHub Desktop.
Save ShoMasegi/1321357a8ae685f2b58f7006fb35deaf to your computer and use it in GitHub Desktop.
override func prepare() {
super.prepare()
guard let collectionView = collectionView, let delegate = delegate else {
return
}
guard collectionView.numberOfSections > 0 else { return }
var position: CGFloat = 0.0
(0 ..< numberOfSections).forEach { section in
layoutHeader(position: &position, collectionView: collectionView, delegate: delegate, section: section)
layoutItems(position: position, collectionView: collectionView, delegate: delegate, section: section)
layoutFooter(position: &position, collectionView: collectionView, delegate: delegate, section: section)
}
}
private func layoutHeader(
position: inout CGFloat,
collectionView: UICollectionView,
delegate: CollectionViewLayoutDelegate,
section: Int
) {
....
}
private func layoutItems(
position: CGFloat,
collectionView: UICollectionView,
delegate: CollectionViewLayoutDelegate,
section: Int
) {
....
}
private func layoutFooter(
position: inout CGFloat,
collectionView: UICollectionView,
delegate: CollectionViewLayoutDelegate,
section: Int
) {
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment