How to use images asset catalog in cocoapod library for iOS

前端 未结 11 2322
粉色の甜心
粉色の甜心 2020-12-15 16:38

I have a cocoapod library which contains assets in 2 formats:

  • a .storyboard
  • XCode asset catalog .xcassets (with images)

my podsp

11条回答
  •  执笔经年
    2020-12-15 17:26

    if you are using swift.

    class func loadImage(name: String) -> UIImage? {
        let podBundle = NSBundle(forClass: MyClass.self)
        if let url = podBundle.URLForResource("MyBundleName", withExtension: "bundle") {
            let bundle = NSBundle(URL: url)
            return UIImage(named: name, inBundle: bundle, compatibleWithTraitCollection: nil)
        }
        return nil
    }
    

提交回复
热议问题