Skip to content

Instantly share code, notes, and snippets.

@vladimir-anisimov
Created September 1, 2022 06:46
Show Gist options
  • Save vladimir-anisimov/b7dc65427a694de85fe88e924fff84ab to your computer and use it in GitHub Desktop.
Save vladimir-anisimov/b7dc65427a694de85fe88e924fff84ab to your computer and use it in GitHub Desktop.
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