Created
March 7, 2021 10:37
-
-
Save KrauserHuang/ee62602ffd2e1ff9948517633d54dad8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 建立UICollectionView | |
let myCollectionView = UICollectionView(frame: CGRect(x: 0, y: 20, width: fullScreenSize.width, height: fullScreenSize.height - 20), collectionViewLayout: layout) | |
// 註冊cell來重複利用 | |
myCollectionView.register(MyCollectionViewCell.self, forCellWithReuseIdentifier: "Cell") | |
// 註冊section的header/footer來重複使用 | |
myCollectionView.register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "Header") | |
myCollectionView.register(UICollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "Footer") | |
// 設置委任對象 | |
myCollectionView.delegate = self | |
myCollectionView.dataSource = self | |
view.addSubview(myCollectionView) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment