我有一个包含资源文件夹的捆绑包。我已经阅读了关于使用
UIImage(named: "drop_arrow", inBundle: bundle, compatibleWithTraitCollection: nil)
(它是Swift 3的等效方式)的所有堆栈答案。path = Bundle.main.path(forResource: "LiveUI", ofType: "bundle")
if path != nil { // path with bundle is found
let bundle: Bundle = Bundle.init(path: path!)! // bundle is there
let image: UIImage? = UIImage(named: "HomePlayButton", in: bundle, compatibleWith: nil)
// HomePlayButton exists in the bundle/asset folder
// but image is nil
}
这是我的项目结构:
你能看出这个项目的代码/结构有什么问题吗? 更新! ... 图像被设置为通用的所有分辨率:![enter image description here](https://istack.dev59.com/f2M6I.webp)
UIImage(named: "yourbundlefile.bundle/HomePlayButton.png")!
加载此图像。 - Umesh Verma