RiveViewModel and RiveView. This guide covers integration patterns for UIKit apps, including Storyboard and programmatic approaches.
Quick Start
The fastest way to add a Rive animation to UIKit is usingRiveViewModel:
Integration Approaches
- Programmatic
- Storyboard
Create and configure views entirely in code:
Controlling Animations
Playback Controls
State Machine Interactions
Layout Configuration
Fit and Alignment
Available Options
Fit Modes:.contain- Fit within bounds while maintaining aspect ratio.fill- Fill the entire view.cover- Cover the view while maintaining aspect ratio.fitWidth- Match the view’s width.fitHeight- Match the view’s height.scaleDown- Only scale down if larger.layout- Resize artboard to view size.noFit- No scaling
.topLeft,.topCenter,.topRight.centerLeft,.center,.centerRight.bottomLeft,.bottomCenter,.bottomRight
Loading from URL
Working with RiveView Directly
For advanced use cases, you can work withRiveView directly without a view model:
State Machine Inputs
Trigger Inputs
Boolean Inputs
Number Inputs
Nested Artboard Inputs
Lifecycle Management
Proper Cleanup
Performance Optimization
Frame Rate Control
Memory Management
Best Practices
- Use RiveViewModel - Prefer
RiveViewModelover directRiveViewmanipulation for easier state management - Frame Management - Set frames in
viewWillAppearor use Auto Layout constraints - Pause When Hidden - Pause animations in
viewWillDisappearto save battery - Cleanup Resources - Stop animations and deregister views in
deinit - Handle Errors - Wrap
RiveModelinitialization in do-catch blocks - Reuse View Models - Create view models once and reuse them
Next Steps
- Loading Assets - Learn different ways to load .riv files
- Touch Events - Handle user interactions
- RiveViewModel API - Complete API documentation