Bounce experiment

This commit is contained in:
Isaac
2025-10-04 00:44:30 +08:00
parent 1ff56084fe
commit 4b04a6c69e
7 changed files with 165 additions and 19 deletions

View File

@@ -322,8 +322,9 @@ public extension CALayer {
return animation
}
func animateSpring(from: AnyObject, to: AnyObject, keyPath: String, duration: Double, delay: Double = 0.0, initialVelocity: CGFloat = 0.0, damping: CGFloat = 88.0, removeOnCompletion: Bool = true, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
func animateSpring(from: AnyObject, to: AnyObject, keyPath: String, duration: Double, delay: Double = 0.0, initialVelocity: CGFloat = 0.0, stiffness: CGFloat = 900.0, damping: CGFloat = 88.0, removeOnCompletion: Bool = true, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
let animation = makeSpringBounceAnimation(keyPath, initialVelocity, damping)
animation.stiffness = stiffness
animation.fromValue = from
animation.toValue = to
animation.isRemovedOnCompletion = removeOnCompletion