Skip to content

Instantly share code, notes, and snippets.

@andresbrun
Last active January 2, 2017 18:15
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 andresbrun/f7f507e9cae906c87255f76d44dbc1c7 to your computer and use it in GitHub Desktop.
Save andresbrun/f7f507e9cae906c87255f76d44dbc1c7 to your computer and use it in GitHub Desktop.
Shows how to configure UIDynamics to dismiss the modal.
let pushBehaviour = UIPushBehavior(items: [mainModalView], mode: .instantaneous)
pushBehaviour.pushDirection = velocity.vector * Constants.pushForceRatio
pushBehaviour.setTargetOffsetFromCenter(offset, for: mainModalView)
animator.addBehavior(pushBehaviour)
animator.addBehavior(gravityBehaviour)
animator.removeBehaviors(itemsAttachmentBehaviours)
// Handy extension
public extension CGPoint {
var vector: CGVector {
return CGVector(dx: x, dy: y)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment