Last active
March 10, 2018 17:25
-
-
Save usagimaru/d1ceb60792b5925b1d9b20d9db9453a4 to your computer and use it in GitHub Desktop.
Reset `scrollsToTop` flags to all scrollviews
This file contains 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
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