Skip to content

Instantly share code, notes, and snippets.

@swiftcafex
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swiftcafex/4c76e09c6eca588f9976 to your computer and use it in GitHub Desktop.
Save swiftcafex/4c76e09c6eca588f9976 to your computer and use it in GitHub Desktop.
UIImage 的 extension 用来通过枚举项来初始化图片资源
// www.swiftcafe.io 更多技术内容
extension UIImage {
enum AssetIdentifier : String {
case Flower = "ic_flower"
case Mushroom = "ic_mushroom"
case Mario = "ic_mario"
}
convenience init!(assetIdentifier : AssetIdentifier) {
self.init(named: assetIdentifier.rawValue)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment