How to use images asset catalog in cocoapod library for iOS

前端 未结 11 2405
粉色の甜心
粉色の甜心 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:24

    Swift 3 version

    private func getImageFromBundle(name: String) -> UIImage {
       let podBundle = Bundle(for: YourClass.self)
       if let url = podBundle.url(forResource: "YourClass", withExtension: "bundle") {
          let bundle = Bundle(url: url)
          return UIImage(named: name, in: bundle, compatibleWith: nil)!
       }
       return UIImage()
    }
    

提交回复
热议问题