SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top