Skip to content

Instantly share code, notes, and snippets.

@froggomad
Created June 18, 2021 16:46
Show Gist options
  • Save froggomad/03b7e80ce7f737545fe98fe9113e0712 to your computer and use it in GitHub Desktop.
Save froggomad/03b7e80ce7f737545fe98fe9113e0712 to your computer and use it in GitHub Desktop.
extension TitledCollectionView {
class Layout: UICollectionViewFlowLayout {
static let heightConstant: CGFloat = 150
override func prepare() {
super.prepare()
guard let collectionView = collectionView else { return }
// TODO: why -13 to make the size even? section insets?
itemSize = CGSize(width: collectionView.frame.width / 3 - 13, height: Self.heightConstant - 40)
scrollDirection = .horizontal
sectionInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment