SDWebImage check if UIImage get from the cache
I am using SDWebImage to download and cache image in the device. I would
like to show some animation after the download process but the cache
image.
Here is my code:
__weak typeof(self) weakSelf = self;
//SDWebImage Method
[self.imageView setImageWithURL:imageUrl
placeholderImage:[UIImage
imageNamed:@"imageview_placeholder.png"]
completed:^(UIImage *image, NSError *error,
SDImageCacheType cacheType) {
if (!error && image)
{
if (weakSelf.spinner) [weakSelf.spinner
removeFromSuperview];
// if downloaded from server, add animation
if (isDownloadedFromServer])
{
[weakSelf.imageView setAlpha:0.0];
[weakSelf.imageView setImage:image];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[weakSelf.imageView setAlpha:1.0];
[UIView commitAnimations];
}
else
{
[weakSelf.imageView setImage:image];
}
}
}];
Is there any way to distinguish between cache or download?
Thanks!
No comments:
Post a Comment