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..
Using LOTAnimationView with Auto Layout in Storyboard
Asked Answered
Should be set like this in latest Lottie version:
and set animation name 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()
}
}
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.
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
© 2022 - 2024 — McMap. All rights reserved.