Skip to content

Instantly share code, notes, and snippets.

@AghaShahriyar
Created October 14, 2019 13:23
Show Gist options
  • Save AghaShahriyar/5ff567c4a8936591f69f3a54867bd6eb to your computer and use it in GitHub Desktop.
Save AghaShahriyar/5ff567c4a8936591f69f3a54867bd6eb to your computer and use it in GitHub Desktop.
Load image using Extension in swift
extension UIImageView {
func loadImage(URL : URL?, name : String) {
self.setImageForName(name, circular: true, textAttributes: nil)
self.sd_setImage(with:URL) { (image, error, cache, url) in
if image == nil {
self.setImageForName(name, circular: true, textAttributes: nil)
}
}
}
}
// POD Libraries
// InitialsImageView
// SDWebImage
// In you ViewController
self.profileImage.loadImage(URL: imageUrl), name: name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment