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

1

5

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

Kalinin answered 4/3, 2020 at 19:55 Comment(2)
Don't add links to the code, add the code in the question itself. That will help the question be more useful in the long term (years).Floridafloridia
Screenshots of code are not sufficient for a question about code to be on-topic. Please edit the question to include a minimal reproducible example or this question risks being closed.Phonography
W
12

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")
                        }
    })
Weaponeer answered 4/3, 2020 at 20:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.