Created
October 14, 2019 13:23
-
-
Save AghaShahriyar/5ff567c4a8936591f69f3a54867bd6eb to your computer and use it in GitHub Desktop.
Load image using Extension in swift
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
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