airbnb / lottie-ios

An iOS library to natively render After Effects vector animations
http://airbnb.io/lottie/
Apache License 2.0
25.47k stars 3.71k forks source link

Only One Circle Appears in the Animation Instead of Two #2407

Open brstorm-jonghyunlee opened 1 month ago

brstorm-jonghyunlee commented 1 month ago

Which Version of Lottie are you using?

Lottie 4.4.3

Expected Behavior

https://github.com/airbnb/lottie-ios/assets/144753334/82d2da99-f50f-4b94-84fc-6318334337a4

Actual Behavior

https://github.com/airbnb/lottie-ios/assets/144753334/86281275-b196-4de0-8007-69d7e6d1bfb5

Animation JSON

Lottie Animation Link doubleSpinner.json

Code

Since our main app is based on SwiftUI, we are using a wrapper around LottieAnimationView. However, we have also tried using the SwiftUI version of LottieView, and we have attempted the solutions suggested in other issues, including changing the RenderingEngine. Unfortunately, the problem persists.

Thank you for always providing such a great library.


import Lottie import SwiftUI

struct CustomLottieView: UIViewRepresentable { var animationFileName: String let loopMode: LottieLoopMode

func updateUIView(_ uiView: UIView, context: Context) {}

func makeUIView(context: Context) -> UIView {
    let view = UIView(frame: .zero)

    let configuration = LottieConfiguration(renderingEngine: .mainThread)
    let animationView = LottieAnimationView(name: animationFileName, configuration: configuration)

    animationView.loopMode = loopMode
    animationView.contentMode = .scaleAspectFill
    animationView.translatesAutoresizingMaskIntoConstraints = false

    view.addSubview(animationView)

    NSLayoutConstraint.activate([
        animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
        animationView.heightAnchor.constraint(equalTo: view.heightAnchor),
        animationView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
        animationView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
    ])

    animationView.play()

    return view
}

}

if DEBUG

Preview {

CustomLottieView(animationFileName: "doubleSpinner",
                 loopMode: .loop)
.frame(width: 200, height: 200)

}

endif

brstorm-jonghyunlee commented 1 month ago

Additionally, the same issue occurs with .lottie file formats.