Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func numberOfSections(in collectionView: UICollectionView) -> Int {
- // 返回 HomeSection 所有情況的數目
- return HomeSection.allCases.count
- }
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- // 透過 HomeSection(rawValue: section) 來讓 section 轉換成 HomeSection 的情況
- // 若是 section 超出範圍 (nil),那就回傳 0
- guard let homeSection = HomeSection(rawValue: section) else { return 0 }
- // 判斷 homeSection 是否為功能區塊,如果是就返回功能區塊陣列數目;如果不是則都返回 1
- return homeSection == .features ? features.count : 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement