Limited offer — lifetime access:$75$60
Rive · iOS

Using Rive icons in iOS

RiveViewModel manages the runtime. triggerInput and setBooleanInput drive the state machine animations.

1

Install the Rive Swift Package

In Xcode: File → Add Package Dependencies. Paste the URL below.

https://github.com/rive-app/rive-ios.git
2

Load the animation

Drag your .riv file into Xcode (check 'Copy items if needed'), then create a RiveViewModel with the file name and state machine.

JS
import RiveRuntime

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        let riveModel = RiveViewModel(
            fileName: "your_animation",
            stateMachineName: "State Machine 1"
        )
        let riveView = riveModel.createRiveView()
        riveView.frame = CGRect(x: 100, y: 100, width: 150, height: 150)
        view.addSubview(riveView)
    }
}
3

Fire state machine inputs

Trigger the Hover and Clicked animations included in every Unicorn Icon.

JS
// Fire a trigger input (one-shot animation)
riveModel.triggerInput("Clicked")

// Set a boolean input (hold state)
riveModel.setBooleanInput("Hover", value: true)   // hover start
riveModel.setBooleanInput("Hover", value: false)  // hover end

// Read a value
let isActive = riveModel.getBooleanInput("IsActive")

Common questions

Does this work with SwiftUI?

Yes. Use RiveViewModel as @ObservedObject and call riveModel.createRiveView(). Rive has native SwiftUI support.

How do I add the .riv file?

Drag it into the project navigator with "Copy items if needed" checked. Reference it by name without the .riv extension.

What inputs do Unicorn Icons include?

All icons have a state machine called State Machine 1 with boolean input Hover and trigger Clicked.

Get your animated icons

Browse icons ready for iOS — free to download.

Browse icons