【问题标题】:After Effects animation loaded with Lottie not playing加载了 Lottie 的 After Effects 动画未播放
【发布时间】:2017-12-10 23:35:05
【问题描述】:

我正在使用Lottie library for iOS 并尝试加载下载LottieFiles 的.json 格式的动画。

我在viewDidLoad() 方法中使用此代码:

let animationView = LOTAnimationView(name: "infinite_rainbow")
animationView.loopAnimation = true
animationView.frame = CGRect(x: 0, y: 0, width: 400, height: 400)
animationView.center = self.view.center
animationView.contentMode = .scaleAspectFill
view.addSubview(animationView)
animationView.play()

问题:只显示第一帧,但没有播放动画。我尝试了几个文件,但结果都是一样的。

我正在使用:

  • Xcode 9.1

  • 斯威夫特 4

  • Lottie-ios v2.1.5 (cocoapod)

【问题讨论】:

    标签: ios animation after-effects lottie


    【解决方案1】:

    使用内容模式 .scaleAspectFit 而不是 .scaleAspectFill

        let animationView = LOTAnimationView(name: "infinite_rainbow")
        animationView.loopAnimation = true
        animationView.frame = CGRect(x: 0, y: 0, width: 400, height: 400)
        animationView.center = self.view.center
        animationView.contentMode = .scaleAspectFit
        view.addSubview(animationView)
        animationView.play()
    

    【讨论】:

      【解决方案2】:

      尝试在 viewDidAppear 中调用 .play()

      【讨论】:

        猜你喜欢
        • 2020-10-24
        • 2013-09-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-02
        • 2021-03-23
        • 1970-01-01
        相关资源
        最近更新 更多