Using LOTAnimationView with Auto Layout in Storyboard
Asked Answered
D

3

7

Is there a way to use LOTAnimationView (Lottie framework) with auto layout? I tried setting the class of a UIView to LOTAnimationView in my storyboard, but getting nil IB outlet..

Doodlesack answered 6/4, 2018 at 18:50 Comment(0)
A
9

Should be set like this in latest Lottie version:

enter image description here

and set animation name here:

enter image description here

and here is example code:

import UIKit
import Lottie

class ViewController: UIViewController {

    @IBOutlet weak var animationView: AnimationView!

    override func viewDidLoad() {
        super.viewDidLoad()

        animationView.play()

    }
}
Allbee answered 17/5, 2019 at 3:53 Comment(0)
G
6

enter image description here

Take an outlet of LOTAnimatedControl.

Assign your JSON file to LOTAnimationView

lot.animationView.setAnimation(named: "checked_done_")

Complete example:

import UIKit
import Lottie

class ViewController: UIViewController {
    @IBOutlet weak var lot: LOTAnimatedControl!
    override func viewDidLoad() {
        super.viewDidLoad()
        lot.animationView.setAnimation(named: "youranimationjsonfile")
        lot.animationView.play()
    }
}

Hope this will help you.

Goldarn answered 6/7, 2018 at 12:50 Comment(0)
J
1

Update for the latest Lottie version with Ashish Kakkad's comment.

Change class name AnimationView instead of LOTAnimatedControl,

and then set property animationName from Interface Builder

Jam answered 13/5, 2019 at 6:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.