我正在尝试在我的 iOS 应用程序中使用 Lottie 动画,但我无法让它们工作。我见过人们使用 LOTAnimationViews
但我无法导入或使用此类。我添加了一个 Animation 文件夹,其中包含我的动画。
View Controller :
class CardStackViewController: UIViewController, CLLocationManagerDelegate, NetworkManagerDelegate {
...
private let animationView = AnimationView()
...
...
func didFail(with error: Error) {
if let animation = Animation.named("error", subdirectory: "Animations") {
animationView.animation = animation
animationView.loopMode = .loop
view.addSubview(animationView)
animationView.play()
}
print("---DIDFAIL WITH ERROR---", error.localizedDescription, error)
}
...
}
最佳答案
以上
import lottie
并给 View 一个框架
animationView.animation = animation
animationView.frame = ///
关于ios - lottie 动画在 ios 中为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59238485/