Created
January 22, 2016 02:00
-
-
Save kanekomasanori/30837a4b4a0171988e0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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