Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  2. return (self.setHomeBanners?.count ?? 0) * 2
  3. }
  4.  
  5. func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
  6. var offset = collectionView.contentOffset
  7. // horizontal
  8. // let height = collectionView.contentSize.height
  9. // if offset.y < height/4 {
  10. // offset.y += height/2
  11. // collectionView.setContentOffset(offset, animated: false)
  12. // } else if offset.y > height/4 * 3 {
  13. // offset.y -= height/2
  14. // collectionView.setContentOffset(offset, animated: false)
  15. // }
  16.  
  17. let width = collectionView.contentSize.width
  18. if offset.x < width/4 {
  19. offset.x += width/2
  20. collectionView.setContentOffset(offset, animated: false)
  21. } else if offset.x > width/4 * 3 {
  22. offset.x -= width/2
  23. collectionView.setContentOffset(offset, animated: false)
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement