Skip to content

Instantly share code, notes, and snippets.

@agammahajan1
Created December 29, 2019 10:54
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 agammahajan1/9b57cd1292c4c8055608d70d588487b6 to your computer and use it in GitHub Desktop.
Save agammahajan1/9b57cd1292c4c8055608d70d588487b6 to your computer and use it in GitHub Desktop.
private func getSpringAnimation(withInitialPostion initialPos: CGPoint, finalPos: CGPoint) -> CASpringAnimation {
let basicAnimation = CASpringAnimation(keyPath: "position")
basicAnimation.fromValue = NSValue(cgPoint: initialPos)
basicAnimation.toValue = NSValue(cgPoint: finalPos)
basicAnimation.duration = basicAnimation.settlingDuration
basicAnimation.damping = 14
basicAnimation.initialVelocity = 5
basicAnimation.isRemovedOnCompletion = false
basicAnimation.fillMode = CAMediaTimingFillMode.forwards
return basicAnimation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment