How do I make a UIScrollView scroll to the top?
Here is a Swift extension that makes it easy:
extension UIScrollView { func scrollToTop() { let desiredOffset = CGPoint(x: 0, y: -contentInset.top) setContentOffset(desiredOffset, animated: true) } }
Usage:
myScrollView.scrollToTop()