Last active
July 2, 2019 06:25
-
-
Save ssebi/7164c6817a7b5bd1a95189584443ed53 to your computer and use it in GitHub Desktop.
Extension to scroll a UIScrollView to any other view, leaving that view on top of the screen after scrolling.
This file contains hidden or 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
extension UIScrollView { | |
func scrollToView(view:UIView, animated: Bool) { | |
if let origin = view.superview { | |
let childStartPoint = origin.convert(view.frame.origin, to: self) | |
self.scrollRectToVisible(CGRect(x: 0.0, | |
y: childStartPoint.y, | |
width: 1.0, | |
height: self.frame.height), | |
animated: animated) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment