Load image from iOS 8 framework

前端 未结 5 663
太阳男子
太阳男子 2020-12-08 07:17

I\'m trying to load an image from an iOS 8 framework that I\'m writing (in Swift). I\'m using Xcode 6 Beta 6

This code does not work (i.e. load image) if the image i

5条回答
  •  情深已故
    2020-12-08 07:57

    The accepted answer didn't work for me. Here's a fool proof way for loading an image embedded in a dynamic framework:

        var bundle = NSBundle(forClass: self.classForCoder)
    
        if let bundlePath = NSBundle(forClass: self.classForCoder).resourcePath?.stringByAppendingString("/MYLIB.bundle"), resourceBundle = NSBundle(path: bundlePath) {
            bundle = resourceBundle
        }
    
        let image = UIImage(named: "my-embedded-image", inBundle: bundle, compatibleWithTraitCollection: nil)
    

提交回复
热议问题