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

Viewed 9607

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. I think there is method in JS method playSegments() which can solve this problem but I would like to code this in swift.

I found a similar problem, but for JS: https://github.com/airbnb/lottie-web/issues/579

This is what I tried but it's not working as I expected: MY_ATTEMPT

1 Answers

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")
                        }
    })
Related