Skip to content

Instantly share code, notes, and snippets.

@kanekomasanori
Created January 22, 2016 02:00
import UIKit
import SDWebImage
extension UIImageView {
func sd_setFadeImageWithURL(url: NSURL!, placeholderImage: UIImage!) {
if let placeholderImage = placeholderImage {
sd_setImageWithURL(url, placeholderImage: placeholderImage, options: .AvoidAutoSetImage) { (image, error, cache, url) -> Void in
if cache == SDImageCacheType.None {
UIView.transitionWithView(self, duration: 0.35, options: [.TransitionCrossDissolve, .CurveEaseOut], animations: { () -> Void in
self.image = image
}, completion: nil)
} else {
self.image = image
}
}
} else {
sd_setImageWithURL(url)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment