Overview
TheRiveLinearAnimationInstance class represents a playable instance of a linear animation. It provides fine-grained control over playback, timing, direction, and loop modes.
Creating Animation Instances
From RiveArtboard
Using RiveModel
Using RiveViewModel
Playback Control
Basic Playback
Time Control
Check Animation Status
Loop Modes
Control how animations repeat:Loop Mode Options
| Mode | Description |
|---|---|
oneShot | Play animation once and stop |
loop | Loop animation continuously from start to end |
pingPong | Play forward, then backward, repeatedly |
autoLoop | Use the loop mode configured in the Rive editor |
Direction
Control animation direction:Timing Information
Access detailed timing data:Animation Name
Complete Example
Simple Animation Playback
SwiftUI Simple Animation
Multiple Animations
Best Practices
Use RiveViewModel for automatic playback
Use RiveViewModel for automatic playback
For most use cases,
RiveViewModel handles animation advancement and rendering automatically.Manual advancement for custom timing
Manual advancement for custom timing
When you need precise control over animation timing, create animation instances directly and call
advance(by:) manually.Respect the didLoop return value
Respect the didLoop return value
The
advance(by:) method returns true when an animation completes a loop. Use this to trigger events or state changes.Related
- State Machines - For interactive animations
- Artboards - Access animations from artboards
- RiveViewModel - High-level animation control