When loading a remote image with sd_setImage, the placeholder image doesn't work with animated gifs. It won't accept FLAnimatedImage (since FLAnimatedImage is not a UIImage subclass) and won't animate a UIImage that is an animated GIF.
@rpstro02 You can pass a UIAnimatedImage created by -[UIImage animatedImageWithImages:duration:]. Which can be shown correctlly. You can call -[UIImage sd_animatedGIFWithData:] to create one.
However, since FLAnimatedImage is not a UIImage subclass, you can not pass one to do placeholder. This will be fixed into 5.x release because we drop out that FLAnimatedImage subspec and introduce own SDAnimatedImage, which is a UIImage subclass.
For now, just use some other way like using UIAnimatedImage, or set the placeholder yourself before calling sd_setImageWithURL: with SDWebImageDelayPlaceholder 馃槄
UIImage.sd_animatedGIF(with: animatedPlaceholderData)
This works. Thank you for the reply.
@rpstro02 Maybe a better way. We can expose the associate object in FLAnimatedImage+WebCache. Then you can create a new FLAnimatedImage, bind this to your UIImage placeholder and call the sd_setImageWithURL:.
In 4.3.0 we introduce this to fix some issue and "store" the FLAnimatedImage into memory cache. But it's read-only because at that time I think it's should be a advacend feature and user should avoid touching this. Now I think it's time to open the ability to set that property.
See #2220
Most helpful comment
@rpstro02 You can pass a
UIAnimatedImagecreated by-[UIImage animatedImageWithImages:duration:]. Which can be shown correctlly. You can call-[UIImage sd_animatedGIFWithData:]to create one.However, since
FLAnimatedImageis not aUIImagesubclass, you can not pass one to do placeholder. This will be fixed into 5.x release because we drop out thatFLAnimatedImagesubspec and introduce ownSDAnimatedImage, which is aUIImagesubclass.For now, just use some other way like using
UIAnimatedImage, or set the placeholder yourself before callingsd_setImageWithURL:withSDWebImageDelayPlaceholder馃槄