Overview
RiveFile is the main entry point for working with Rive files in iOS. It handles loading .riv files from various sources and provides access to artboards, animations, state machines, and data binding view models.
Class Properties
The major version of the Rive runtime (class property).
The minor version of the Rive runtime (class property).
Indicates whether the Rive file is loaded and ready for use.
Delegate for callbacks when a file has finished loading. Conforms to
RiveFileDelegate protocol.The number of view models in the file.
Initialization Methods
From Byte Array
Array of bytes containing the Rive file data.
Whether to load assets from Rive’s CDN.
Custom block for loading assets. Called with
RiveFileAsset* asset, NSData* data, and RiveFactory* factory.Pointer to an error object that will be set if initialization fails.
From Bytes
Pointer to raw bytes containing the Rive file data.
Length of the byte array.
From NSData
NSData object containing the Rive file data.
From Resource
Name of the resource file in the app bundle.
File extension of the resource (e.g., “riv”). Optional if included in resourceName.
From HTTP URL
HTTP URL of the Rive file to load.
Delegate that receives callbacks when loading completes or fails.
Artboard Methods
artboard:
Returns a reference to the default artboard.Pointer to an error object that will be set if the operation fails.
The default artboard, or nil if an error occurs.
artboardCount
Returns the number of artboards in the file.The number of artboards.
artboardFromIndex:error:
Returns the artboard by its index.Zero-based index of the artboard.
Pointer to an error object that will be set if the operation fails.
The artboard at the specified index, or nil if an error occurs.
artboardFromName:error:
Returns the artboard by its name.Name of the artboard as defined in the Rive file.
Pointer to an error object that will be set if the operation fails.
The artboard with the specified name, or nil if an error occurs.
artboardNames
Returns the names of all artboards in the file.Array of artboard names.
Data Binding Methods
viewModelAtIndex:
Returns a view model from the file by index. The index starts at 0, where 0 is the first view model listed in the editor’s “Data” panel from top-to-bottom.The index of the view model.
A view model if one exists by index, otherwise nil.
viewModelNamed:
Returns a view model from the file by name. The name must match the name of a view model in the editor’s “Data” panel.The name of the view model.
A view model if one exists by name, otherwise nil.
defaultViewModelForArtboard:
Returns the default view model for an artboard. The default view model is the view model selected under the “Data Bind” panel for an artboard.The artboard within the RiveFile that contains a data binding view model.
A view model if one exists for the artboard, otherwise nil.
bindableArtboardWithName:error:
Returns a bindable artboard from the file by its name. A bindable artboard is an artboard that can be used with data binding features.The name of the artboard to retrieve. Must match exactly with an artboard name in the Rive file.
Pointer to an error object that will be set if the operation fails.
A bindable artboard if one exists with the specified name, otherwise nil.
defaultBindableArtboard:
Returns the default bindable artboard from the file. A bindable artboard is an artboard that can be used with data binding features.Pointer to an error object that will be set if the operation fails.
The default bindable artboard if one exists, otherwise nil.
RiveFileDelegate Protocol
Delegate protocol for receiving file loading callbacks.riveFileDidLoad:error:
Called when a Rive file has successfully loaded.The RiveFile that finished loading.
Pointer to an error object.
Return YES if loading was successful, NO otherwise.
riveFileDidError:
Called when an error occurs during file loading.The error that occurred.