Skip to content

Instantly share code, notes, and snippets.

@fitsyu
Created June 26, 2019 06:20
Show Gist options
  • Save fitsyu/7fb48fcaf0983ef6348af618214efbfe to your computer and use it in GitHub Desktop.
Save fitsyu/7fb48fcaf0983ef6348af618214efbfe to your computer and use it in GitHub Desktop.
Detect UIView out of screen
extension UIView {
func origin(in view: UIView) -> CGPoint {
return view.convert(CGPoint.zero, from: self)
}
func isVisible(in view: UIView) -> Bool {
return view.frame.contains(self.origin(in: view))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment