Sdwebimage: How can I add a fade in effect?

Created on 23 Oct 2013  路  6Comments  路  Source: SDWebImage/SDWebImage

Hello!
How can I add a fade in effect when the image is retrieved?
BTW, the sample project does not work, it seems

import "webp/decode.h"

is missing in
UIImage+WebP.h
and vender/libwebp folder is empty.
I donwloaded the project as a ZIP file right now.
Thanks.

Most helpful comment

use completed block

[photoImgeView setImageWithURL:[NSURL URLWithString:photoPath] 
    completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
        if (cacheType == SDImageCacheTypeNone) {
            photoImgeView.alpha = 0;
            [UIView animateWithDuration:0.3 animations:^{
                photoImgeView.alpha = 1;
            }];
        } else {
            photoImgeView.alpha = 1;
        }
    }];

All 6 comments

use completed block

[photoImgeView setImageWithURL:[NSURL URLWithString:photoPath] 
    completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
        if (cacheType == SDImageCacheTypeNone) {
            photoImgeView.alpha = 0;
            [UIView animateWithDuration:0.3 animations:^{
                photoImgeView.alpha = 1;
            }];
        } else {
            photoImgeView.alpha = 1;
        }
    }];

Works perfectly! Thanks.
One question regarding memory management, isn't it there a retain cycle in photoImgeView?
I mean, try to change photoImgeView by cell.photoImgeView.
Thanks.

It works fine with UITableViewCell.

Thanks.

It worked thanks @asuralyc

How to change white fadein background for this? Currently fadein is white i want it black or grey?

Was this page helpful?
0 / 5 - 0 ratings