简体   繁体   English

如何在 iOS/Swift/Xcode 中播放一次 Lottie 动画然后逐帧循环?

[英]How to play lottie animation once then loop from frame to frame in iOS/Swift/Xcode?

I'm looking for a solution to play one part of my animation once but the other half on loop while using Lottie Files in Xcode.我正在寻找一种解决方案,在 Xcode 中使用 Lottie Files 时播放我的动画的一部分一次但另一半循环播放。 I think there is method in JS method playSegments() which can solve this problem but I would like to code this in swift.我认为 JS 方法 playSegments() 中有一个方法可以解决这个问题,但我想在 swift 中对此进行编码。

similar problem but in JS : https://github.com/airbnb/lottie-web/issues/579类似的问题,但在 JS 中: https : //github.com/airbnb/lottie-web/issues/579

this is what I tried but it's not working as I expected : MY_ATTEMPT这是我尝试过的,但没有按我预期的那样工作: MY_ATTEMPT

thanks for your time and help !感谢您的时间和帮助!

Have you tried to play the second part after the completion of the first one?你有没有试过在完成第一部分后演奏第二部分?

animationView.play(fromProgress: 0,
                       toProgress: 1,
                       loopMode: LottieLoopMode.playOnce,
                       completion: { (finished) in
                        if finished {
                          print("Animation Complete, Start second one")
                        } else {
                          print("Animation cancelled")
                        }
    })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM