Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation to resize LottieView with auto layout constraints is not working when upgrade lottie-ios from 3.1.8 to 4.4.0 #2359

Open
tungnv87 opened this issue Apr 3, 2024 · 0 comments

Comments

@tungnv87
Copy link

tungnv87 commented Apr 3, 2024

Hi support team,
I have an issue relate to resize animation by change height constraint of LottieAnimationView (auto layout), the content animationView cannot scale to fit the container view in animation transaction.

The issue was not appeared on version 3.1.8, but after we upgrade to 4.4.0 and rename the view from AnimationView to LottieAnimationView.

Please take a look to my screen recording and sample project, thanks a lot!

Bellow is the code we are initial animation view, and how we animate the view:

private func makeLoadingView() -> UIView? {
        let animationView = LottieAnimationView(
            animation: .named(
                "Boat_Loader",
                bundle: Bundle(for: type(of: self))
            )
        )
        animationView.loopMode = .loop
        animationView.contentMode = .scaleAspectFill
        animationView.layer.borderColor = UIColor.red.cgColor
        animationView.layer.borderWidth = 1
        animationView.play()
        animationView.translatesAutoresizingMaskIntoConstraints = false

        return animationView
    }
UIView.animate(withDuration: 2.0, animations: {
            if !sender.isSelected {
                self.constraintHeightLoadingView.constant = 40
            } else {
                self.constraintHeightLoadingView.constant = 200
            }
            self.view.layoutIfNeeded()
            self.lottieContainerView.layoutIfNeeded()
        }, completion: { _ in
        })

Which Version of Lottie are you using?

Lottie 4.4.0

Expected Behavior

Screenshot 2024-04-03 at 11 53 16

Screen recording used Lottie version 3.1.8:
https://github.com/airbnb/lottie-ios/assets/15973908/1008bb96-a517-4e38-8154-77c4265a4c5d

Actual Behavior

Screenshot 2024-04-03 at 11 54 03

Screen recording used Lottie version 4.4.0:

4.4.0.mp4

Sample project file:
TestLottieAnimation.zip

Animation JSON

Boat_Loader.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant