How to use png images with Lottie iOS?
12,335
Solution 1
According to this function
It tries to load it different ways including from the asset catalog -- that's what line 147 in that file would do:
NSArray *components = [asset.imageName componentsSeparatedByString:@"."];
image = [UIImage imageNamed:components.firstObject inBundle:asset.assetBundle compatibleWithTraitCollection:nil];
Solution 2
The answer to your question is YES. Drop in your JSON file and place the images in the assets catalog. I tried it with this sample JSON/assets https://www.lottiefiles.com/1187-puppy-run. One thing to note that on Xcode when you drop the image assets, you may need to move them to 2x.
Solution 3
You can put all images next to the json.
After that you can just play animation:
let animation = LOTAnimationView(name: "LogoAnimation")
animation.play()
Author by
Tom Xue
Updated on June 17, 2022Comments
-
Tom Xue almost 2 years
I tried exporting an after effect file with bodymovin, that after effect file has a few png images. How do we use this with Lottie in iOS? Do we include those images in the asset catalog, and use them alongside the json file?
-
i_ll_be_back over 3 yearsSame solution is valid for Xamarin Forms as well! I looked in many places until I end up here! Great explanation!