Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Detecting stasis
// 1. Let's add UIDynamicAnimatorDelegate to our implemented protocols.
class AnimationViewController: UIViewController, UICollisionBehaviorDelegate, UIDynamicAnimatorDelegate
// 2. Set self as the UIDynamicAnimatorDelegate
lazy var animator: UIDynamicAnimator = {
let lazyDynamicAnimator = UIDynamicAnimator(referenceView: self.animationView)
lazyDynamicAnimator.delegate = self
return lazyDynamicAnimator
}()
// 3. Hanlde stasis, by displaying a message.
func dynamicAnimatorDidPause(animator: UIDynamicAnimator){
self.displayMessage("Stasis! The universe stopped moving.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment