Migrating guide from < 2.x
RiveView
- Core logic for building and manipulating Rive viewsRiveModel
- Describes the configuration model for Rive objectsRiveViewModel
- The main class to interface with when integrating rive, creating a Rive view in some instances. It provides a high-level API that makes it simple to do actions like instantiation, animation playback, layout changes, and more.RiveFile
and RiveView
. With v2.x.x, the pattern becomes simpler, interfacing with one RiveViewModel
.
riveView.setNumberState("Number Test", inputName: "Level", value: 2.0)
riveView.setBooleanState("Boolean Test", inputName: "isSuccess", value: true)
riveView.fireState("Trigger Test", inputName: "trigFail")
In v2.x.x, some of the input state setters have been consolidated and renamed. Additionally, the setters are called on the RiveViewModel
which has the context of the state machine that was instantiated, so there is no longer a need to pass it the name: viewModel.setInput("Level", value: 2.0)
viewModel.setInput("isSuccess", value: true)
viewModel.triggerInput("trigFail")
LoopDelegate
, PlayDelegate
, PauseDelegate
, StopDelegate
, and StateChangeDelegate
. The various functions that get implemented on your end (i.e loop
, play
, pause
, stateChange
, etc.) have been consolidated under 2 main delegates, RivePlayerDelegate
and RiveStateMachineDelegate
with a slightly different function to override.
See the following list of delegates for methods to hook into:
RivePlayerDelegate
- Hook into animation and state machine lifecycle events
player
: (loopedWithModel riveModel: RiveModel?, type: Int) {}
player
: (playedWithModel riveModel: RiveModel?) {}
player
: (pausedWithModel riveModel: RiveModel?) {}
player
: (stoppedWithModel riveModel: RiveModel?) {}
RiveStateDelegate
- Hook into state changes on a state machine lifecycle
stateChange
: (_ stateMachineName: String, _ stateName: String) {}
RiveView
class to help support Rive in the context of applications written in SwiftUI. v2.x.x now supports a more robust pattern for consuming Rive in your SwiftUI applications that fixes several bugs with the existing wrapper approach and provides a closer experience with the new pattern of SwiftUI.
See subsequent runtime pages to learn how to control animation playback, state machines, and more with v2.x.x