Last active
January 2, 2017 18:15
-
-
Save andresbrun/f7f507e9cae906c87255f76d44dbc1c7 to your computer and use it in GitHub Desktop.
Shows how to configure UIDynamics to dismiss the modal.
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
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