Search code examples
iosjsonswiftpnglottie

Can I use static images for lottie instead of a json file?


While lottie is used to animate images based on a json file, I'm in a situation in my project where I may suddenly have a static image (png or whatever) instead. So my question is, how do I make it accept and display a static image?

With a json file, you do it like this:

lot?.animation = Animation.named(res) //res == json file name
lot?.play()

Now it can't accept image names like this (res being the name of the png); it doesn't show anything at all. So how would I go about displaying the image properly?


Solution

  • lottie behaviour does not accept static images, only accepts json coded animations, my recommendation is to put some UIImage same size as the AnimationView and do some hide-unhide.