Last active
August 29, 2015 14:23
UIImage 的 extension 用来通过枚举项来初始化图片资源
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
// 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