Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MitchellMalleo/6e21468ed80051f2b668e1bd9a0ef7a0 to your computer and use it in GitHub Desktop.
Save MitchellMalleo/6e21468ed80051f2b668e1bd9a0ef7a0 to your computer and use it in GitHub Desktop.
extension ImageConvertible where Self: RawRepresentable, Self.RawValue == String {
var image: UIImage? {
return UIImage(named: self.rawValue)
}
}
extension UIImage {
convenience init?<T: RawRepresentable>(image: T) where T.RawValue == String {
self.init(named: image.rawValue)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment