Overview
The Rive iOS Runtime provides an experimental data binding API that allows you to:- Create view model instances from your Rive files
- Bind data to artboards and state machines
- Update properties dynamically
- Observe property changes through streams
Basic Usage
Auto-Binding with RiveModel
The simplest way to use data binding is through auto-binding:Manual Data Binding
For more control, you can manually create and bind view model instances using the experimental API:Working with Properties
Property Types
View model instances support multiple property types:StringProperty- String valuesNumberProperty- Float valuesBoolProperty- Boolean valuesColorProperty- Color valuesEnumProperty- Enum case names as stringsTriggerProperty- One-time eventsImageProperty- Image assetsArtboardProperty- Artboard referencesViewModelInstanceProperty- Nested view modelsListProperty- Lists of view model instances
Reading Property Values
Setting Property Values
Observing Property Changes
Use value streams to observe property changes:Firing Triggers
Working with Nested View Models
Working with Lists
Complete Example
Here’s a complete example from the Rive iOS examples:Data Binding Modes
When working with state machines, you can control data binding behavior:Best Practices
- Strong References: Always maintain a strong reference to view model instances you need to update
- Property Caching: Properties are cached when created, so you can safely recreate them from the same instance
- Manual Advance: When not playing, call
riveView?.advance(delta: 0)after updating properties to refresh the view - Error Handling: Always handle potential errors when reading property values
- Stream Cleanup: Value streams continue until cancelled or the instance is deallocated
See Also
- Rive Text - Working with dynamic text
- Rive Events - Event system integration