Use this file to discover all available pages before exploring further.
Artboards are the canvas containers in Rive that hold your graphics, animations, and state machines. Each .riv file can contain multiple artboards, allowing you to organize related animations in a single file.
The RiveArtboard class represents an instance of an artboard from a Rive file. It provides access to animations, state machines, and allows you to advance time and render content.
do { let file = try RiveFile(name: "truck") // Get the default artboard let artboard = try file.artboard() // Get artboard by name let namedArtboard = try file.artboard(fromName: "Square") // Get artboard by index let indexedArtboard = try file.artboard(from: 0)} catch { print("Error loading artboard: \(error)")}
do { let model = try RiveModel(fileName: "truck") // Set artboard by name try model.setArtboard("Square") // Set artboard by index try model.setArtboard(0) // Set default artboard try model.setArtboard() // Access the artboard let artboard = model.artboard} catch { print("Error setting artboard: \(error)")}
// Get animation countlet count = artboard.animationCount()print("This artboard has \(count) animations")// List all animation nameslet names = artboard.animationNames()print("Animations: \(names)")// Get animation by namedo { let animation = try artboard.animation(fromName: "idle")} catch { print("Animation not found")}// Get animation by indexdo { let animation = try artboard.animation(from: 0)} catch { print("Animation not found")}
// Get state machine countlet count = artboard.stateMachineCount()// List all state machine nameslet names = artboard.stateMachineNames()// Get state machine by namedo { let sm = try artboard.stateMachine(fromName: "State Machine 1")} catch { print("State machine not found")}// Get default state machineif let defaultSM = artboard.defaultStateMachine() { print("Using default state machine")}
// Get text run by nameif let textRun = artboard.textRun("username") { textRun.text = "John Doe"}// Get text run with pathif let textRun = artboard.textRun("label", path: "header") { textRun.text = "Welcome"}