Skip to content

Instantly share code, notes, and snippets.

@noppefoxwolf
Created February 9, 2023 23:22
Show Gist options
  • Save noppefoxwolf/4db73a43a83f4a96bddef8b57a95a7a1 to your computer and use it in GitHub Desktop.
Save noppefoxwolf/4db73a43a83f4a96bddef8b57a95a7a1 to your computer and use it in GitHub Desktop.
simulate statusbar action.
extension UIWindowScene {
func scrollToTop() {
guard let window = keyWindow else { return }
var nextResponder: UIResponder? = window.hitTest(window.center, with: UIEvent())
while let responder = nextResponder?.next {
if let scrollView = responder as? UIScrollView {
scrollView.setContentOffset(.zero, animated: true)
}
nextResponder = responder
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment