Last active
August 29, 2015 14:23
-
-
Save swiftcafex/4c76e09c6eca588f9976 to your computer and use it in GitHub Desktop.
UIImage 的 extension 用来通过枚举项来初始化图片资源
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
// 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