ios - lottie 动画在 ios 中为 nil

标签 ios swift lottie

我正在尝试在我的 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/

相关文章:

ios - 有效地找到给定点所在的 NSManagedObject(多边形)

android - 如何根据对象模型的内容使用自定义小部件创建ListView

ios - 尝试从 NSMutableArray 填充 UITableView 时应用程序崩溃

ios - 我将如何从一系列不同的单词或句子中淡入和淡出?

javascript - 如何在 componentWillReceiveProps 上运行 Lottie 动画?

ios - Lottie 在 iOS 上与用户交互

javascript - 使用绑定(bind)自取消事件

ios - 找不到框架.xcframework

ios - UITableViewCell 的详细文本被截断/超出设备宽度

ios - Swift 4.2 错误 dyld : Symbol not found: _OBJC_CLASS_$_MDCSnackbarManager implementing ios Material Design's snackbar