SDWebImage / SDWebImageLottiePlugin

SDWebImage integration with Lottie Animation using remote JSON files
MIT License
19 stars 10 forks source link

Add the support to provide the NSBundle during lottie URL loading for Lottie v3.0 #5

Closed zzzworm closed 2 years ago

zzzworm commented 2 years ago

There are support for provide the NSBundle during lottie URL loading for Lottie v2, but the 1.x branch did not support it, So I add it for the Lottie V3

dreampiggy commented 2 years ago

Hi. This PR seems long-time ago.

Recentlly lottie GitHub close the old performance regression issue, So let's rock to Lottie 3 and pure Swift instead.

I use #7 instead for this PR

dreampiggy commented 2 years ago

After re-check your changes again

One small question: Shouldn't the user set the Lottie.AnimationView.imageProvider before call sd_setImage(with:) API ?🤔 I tested and it work...

dreampiggy commented 2 years ago

@zzzworm

For 1.0.0 Lottie Plugin, you can use both of two ways for custom image provider and bundle.

let url: URL
let animationView: AnimationView
animationView.imageProvider = BundleImageProvider(bundle: bundle, searchPath: nil)
animationView.sd_setImage(with: url)
let json: Data
let animation = try JSONDecoder().decode(Animation.self, from: data)
let lottieImage = LottieImage(animation: animation)
lottieImage.imageProvider = BundleImageProvider(bundle: bundle, searchPath: nil)
let poster = lottieImage.animatedImageFrame(at: 0))

See more in Tests.swift