Skip to content

Instantly share code, notes, and snippets.

@KrauserHuang
Created March 7, 2021 10:04
Show Gist options
  • Save KrauserHuang/b02eabdf9a9dea4e886d8715d2daafdf to your computer and use it in GitHub Desktop.
Save KrauserHuang/b02eabdf9a9dea4e886d8715d2daafdf to your computer and use it in GitHub Desktop.
fullScreenSize = UIScreen.main.bounds.size
view.backgroundColor = .white
// 建立UICollectionViewFloatLayout
let layout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)
// 設定cell上下間距
layout.minimumLineSpacing = 5
// 設定cell尺寸
layout.itemSize = CGSize(width: fullScreenSize.width / 3 - 10, height: fullScreenSize.width / 3 - 10)
// 設定header/footer大小
layout.headerReferenceSize = CGSize(width: fullScreenSize.width, height: 40)
layout.footerReferenceSize = CGSize(width: fullScreenSize.width, height: 40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment