SpringAnimation
public class SpringAnimation : Animation
An animation that applies a spring-like force to a layer’s properties.
SpringAnimation(type: .position)
.duration(duration)
.from(x, y)
.to(x, y)
.resetOnStop(true)
.springVelocity(Velocity)
.springBounciness(Bounciness)
.springSpeed(Speed)
.springTension(Tension)
-
Sets the initial velocity of the object attached to the spring.
Declaration
Swift
@discardableResult public func springVelocity(_ velocity: Float) -> SelfParameters
velocityThe initial velocity of the object attached to the spring.
Return Value
Self
-
Sets the velocitys of the object attached to the spring.
Declaration
Swift
public func springVelocity(_ velocity: Array<Float>) -> SelfParameters
velocityThe velocitys of the object attached to the spring.
Return Value
Self
-
Sets the bounce of the object attached to the spring. Together with the springSpeed value, can change the animation effect. The larger the value, the larger the spring motion range, and the greater the vibration and elasticity. Defined as a value in the range of [0,20]. Default is 4.
Declaration
Swift
@discardableResult public func springBounciness(_ bounce: Float) -> SelfParameters
bounceThe bounce of the object attached to the spring.
Return Value
Self
-
Sets the speed of the object attached to the spring. Together with the springBounciness value, can change the animation effect. A higher value increases the damping capacity of the spring, resulting in a faster initial speed and faster rebound deceleration. Defined as a value in the range of [0,20] . Default is 12.
Declaration
Swift
@discardableResult public func springSpeed(_ speed: Float) -> SelfParameters
speedThe speed of the object attached to the spring.
Return Value
Self
-
Set the tension of the object attached to the spring. Dynamic tension can be used on elasticity and speed to fine-tune the animation effect.
Declaration
Swift
@discardableResult public func springTension(_ tension: Float) -> SelfParameters
tensionThe tension of the object attached to the spring.
Return Value
Self
-
Set the friction of the object attached to the spring. Dynamic friction can be used on elasticity and speed to fine-tune animation effects.
Declaration
Swift
@discardableResult public func springFriction(_ friction: Float) -> SelfParameters
frictionThe friction of the object attached to the spring.
Return Value
Self
-
Set the mass of the object attached to the spring. Dynamic mass can be used on elasticity and speed to fine-tune animation effects.
Declaration
Swift
@discardableResult public func springMass(_ mass: Float) -> SelfParameters
massThe mass of the object attached to the spring.
Return Value
Self
SpringAnimation Class Reference