-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Lottie 4.0.1 issue under iOS 16.2 in SwiftUI #1891
Comments
Ah I think I've found out: When compiling under Lottie 3.5.0 I get at least the information that I tried the same under Lottie 4.0.1 and it worked. (i.e. replacing Would have been nice if the deprecation-information would still show under 4.0.1. import SwiftUI
import Lottie
struct LottieView: UIViewRepresentable {
var lottieFile: String
var loopMode: LottieLoopMode = .playOnce
var animationView = LottieAnimationView()
func makeUIView(context: UIViewRepresentableContext<LottieView>) -> UIView {
let view = UIView()
animationView.animation = LottieAnimation.named(lottieFile)
animationView.contentMode = .scaleAspectFill
animationView.loopMode = loopMode
animationView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(animationView)
NSLayoutConstraint.activate([
animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
animationView.heightAnchor.constraint(equalTo: view.heightAnchor)
])
return view
}
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieView>) {
animationView.play()
}
} |
Closing this issue since you found the workaround. As you noticed we renamed |
Which Version of Lottie are you using?
Lottie 4.0.1
Expected Behavior
On my previous Lottie version 3.4.1, everything was fine. But now with 4.0.1 my code no longer compiles.
I am using SwiftUI under iOS 16.2, XCode 14.2 and Swift 5.7.2
Here is my code of the LottieView under SwiftUI
Actual Behavior
Here a screenshot of the error messages when compiling under Lottie 4.0.1
(it seems to no longer find the AnimationView() for some reason.
What do I need to change when using Lottie 4.0.2 under iOS 16.2 in SwiftUI ??
The text was updated successfully, but these errors were encountered: