Skip to content

Instantly share code, notes, and snippets.

@usagimaru
Last active March 10, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save usagimaru/d1ceb60792b5925b1d9b20d9db9453a4 to your computer and use it in GitHub Desktop.
Save usagimaru/d1ceb60792b5925b1d9b20d9db9453a4 to your computer and use it in GitHub Desktop.
Reset `scrollsToTop` flags to all scrollviews
import UIKit
extension UIView {
func resetScrollsToTop(_ targetScrollView: UIScrollView) {
if self is UIScrollView {
(self as! UIScrollView).scrollsToTop = self == targetScrollView
}
for v in subviews {
v.resetScrollsToTop(targetScrollView)
}
}
func findScrollViews() {
if self is UIScrollView {
print(#function, "scrollsToTop: \((self as! UIScrollView).scrollsToTop), \(self.hash), \(self.frame)")
}
for v in subviews {
v.findScrollViews()
}
}
}
/*
view.resetScrollsToTop(targetScrollView)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment