Skip to content

Instantly share code, notes, and snippets.

@ssebi
Last active July 2, 2019 06:26
Show Gist options
  • Save ssebi/4ff1d89fa7966639469ff691f4b452df to your computer and use it in GitHub Desktop.
Save ssebi/4ff1d89fa7966639469ff691f4b452df to your computer and use it in GitHub Desktop.
Extension to scroll a UIScrollView to top
extension UIScrollView {
func scrollToTop(animated: Bool) {
let topOffset = CGPoint(x: 0, y: -contentInset.top)
setContentOffset(topOffset, animated: animated)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment