Skip to content

Instantly share code, notes, and snippets.

@andresbrun
Created January 2, 2017 18:25
Show Gist options
  • Save andresbrun/771dcc8ebf8e8672b7916c68840b52e4 to your computer and use it in GitHub Desktop.
Save andresbrun/771dcc8ebf8e8672b7916c68840b52e4 to your computer and use it in GitHub Desktop.
modalViewExitBehaviour = UIDynamicItemBehavior(items: [targetView])
// Action is called in every animation step
modalViewExitBehaviour.action = { [unowned self] _ in
// Check if all views are outside of the reference frame
if !self.allViews.contains(where: { $0.frame.intersects(self.superview.bounds) }) {
self.onDismiss?()
}
}
animator?.addBehavior(modalViewExitBehaviour)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment