Created
September 1, 2022 06:46
-
-
Save vladimir-anisimov/b7dc65427a694de85fe88e924fff84ab to your computer and use it in GitHub Desktop.
This file contains hidden or 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 UIImage { | |
class func with(fileNamed: String, | |
withExtension fileExtension: String = ".png") -> UIImage { | |
guard let url = Bundle.main.url(forResource: fileNamed, withExtension: fileExtension) else { return UIImage() } | |
guard let data = try? Data(contentsOf: url) else { return UIImage() } | |
return UIImage(data: data) ?? UIImage() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment