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) -> Self
Parameters
velocity
The 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>) -> Self
Parameters
velocity
The 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) -> Self
Parameters
bounce
The 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) -> Self
Parameters
speed
The 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) -> Self
Parameters
tension
The 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) -> Self
Parameters
friction
The 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) -> Self
Parameters
mass
The mass of the object attached to the spring.
Return Value
Self