有没有办法在LOTAnimationView
自动布局中使用(Lottie 框架)?UIView
我尝试LOTAnimationView
在我的情节提要中将a 的类设置为,但获得了nil
IB 出口..
4060 次
3 回答
6
取一个出口LOTAnimatedControl
。
将您的 JSON 文件分配给LOTAnimationView
lot.animationView.setAnimation(named: "checked_done_")
完整示例:
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()
}
}
希望这会帮助你。
于 2018-07-06T12:50:38.490 回答
1
使用Ashish Kakkad的评论更新最新的 Lottie 版本。
更改类名AnimationView
而不是LOTAnimatedControl
,
然后animationName
从 Interface Builder设置属性
于 2019-05-13T06:25:33.670 回答