Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- return (self.setHomeBanners?.count ?? 0) * 2
- }
- func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
- var offset = collectionView.contentOffset
- // horizontal
- // let height = collectionView.contentSize.height
- // if offset.y < height/4 {
- // offset.y += height/2
- // collectionView.setContentOffset(offset, animated: false)
- // } else if offset.y > height/4 * 3 {
- // offset.y -= height/2
- // collectionView.setContentOffset(offset, animated: false)
- // }
- let width = collectionView.contentSize.width
- if offset.x < width/4 {
- offset.x += width/2
- collectionView.setContentOffset(offset, animated: false)
- } else if offset.x > width/4 * 3 {
- offset.x -= width/2
- collectionView.setContentOffset(offset, animated: false)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement