Created
July 2, 2017 15:39
-
-
Save ruan65/3037f077e30532f39aba074a4b384067 to your computer and use it in GitHub Desktop.
Method for catching CollectionView scroll to top or bottom in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func scrollViewDidScroll(_ scrollView: UIScrollView) { | |
if (scrollView.contentOffset.y < -250){ | |
//reach top | |
print("Topppppppppppppppppppp") | |
} | |
if (scrollView.contentOffset.y >= 250 + (scrollView.contentSize.height - scrollView.frame.size.height)) { | |
//reach bottom | |
print("Bottommmmmmm........") | |
} | |
if (scrollView.contentOffset.y >= 0 && scrollView.contentOffset.y < (scrollView.contentSize.height - scrollView.frame.size.height)){ | |
//not top and not bottom | |
print("Just scrolled") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment