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

Using Lottie icons in iOS

Swift Package Manager install, add your JSON file to Xcode, then LottieAnimationView with a file name. That's the whole setup.

1

Install via Swift Package Manager

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

https://github.com/airbnb/lottie-ios
2

Add the animation to your ViewController

Drag your JSON file into Xcode (check 'Copy items if needed'), then create a LottieAnimationView with the file name.

JS
import Lottie

class ViewController: UIViewController {
    var animationView: LottieAnimationView!

    override func viewDidLoad() {
        super.viewDidLoad()

        animationView = LottieAnimationView(name: "your_animation")
        animationView.frame = CGRect(x: 0, y: 0, width: 150, height: 150)
        animationView.center = view.center
        animationView.loopMode = .loop
        animationView.play()
        view.addSubview(animationView)
    }
}
3

Control playback

The animationView instance gives you play, pause, stop, and loop mode control.

JS
animationView.play()
animationView.pause()
animationView.stop()
animationView.loopMode = .playOnce

Common questions

Does Lottie work with SwiftUI?

Yes. Recent versions of lottie-ios ship a native LottieView SwiftUI component. On older versions, wrap LottieAnimationView in UIViewRepresentable.

How do I add the JSON to Xcode?

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

How do I play once and stop?

Set animationView.loopMode = .playOnce before calling play(). It stops on the last frame.

Get your animated icons

Browse icons ready for iOS — free to download.

Browse icons