Why isn't this Lottie animating?

1 month ago 23
ARTICLE AD BOX

this is a small minimal snippet for my code. In this code, I can't seem to start the animation of the Lottie. Why isn't it animating? Can anybody help? Thanks.

import Lottie struct TestLottie: View { let animating: Bool var body: some View { LottieView(animation: .named("loadingSpinnerLight", bundle: Bundle.main)) .configure { $0.contentMode = .scaleAspectFit } .playbackMode(animating ? .playing(.toProgress(1, loopMode: .loop)) : .paused(at: .progress(0))) .resizable() .scaledToFit() .frame(width: 60, height: 60) } } struct MainView: View { @State private var isLottieAnimating = false var body: some View { VStack(alignment: .center) { Text("Test Lottie Animation!") TestLottie(animating: isLottieAnimating) } .onAppear { isLottieAnimating = true } .task { try? await Task.sleep(nanoseconds: 3_000_000_000) isLottieAnimating = false } } }
Read Entire Article