Advertisement
Guest User

Untitled

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