Skip to content

Instantly share code, notes, and snippets.

@aybekckaya
Created May 18, 2019 12:40
Show Gist options
  • Save aybekckaya/8bedb7053870b2c1209fbf27a57b91e1 to your computer and use it in GitHub Desktop.
Save aybekckaya/8bedb7053870b2c1209fbf27a57b91e1 to your computer and use it in GitHub Desktop.
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let currentPage:Int = Int(scrollView.contentOffset.x / scrollView.frame.size.width)
if currentPage == 0 {
self.scrollView.contentOffset = CGPoint(x: scrollView.frame.size.width * CGFloat(numberOfItems), y: scrollView.contentOffset.y)
}
else if currentPage == numberOfItems {
self.scrollView.contentOffset = CGPoint(x: 0, y: scrollView.contentOffset.y)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment