I have a separate bundle of resources that ship with my framework. I want to put and use an asset catalog in that bundle. However UIImage imageNamed: says it uses the current apps main bundle. How do I load an image from an asset catalog in a different bundle?
The trick of using [bundle pathForResource:name ofType:@"png"] doesn't work with the compiled asset catalog. I have verified that the Assets.car file is indeed in the bundle and it contains my images.
An asset catalog is a type of file used to organize and manage different assets and image resolutions used by your app's user interface.
Choose File > New > File. Choose Resource > Asset Catalog, and click Next. Give the asset catalog a name, choose a location, and click Create.
An asset catalog, simply put, is a single folder in Xcode that you use to organize your app's images, icons, colors, and more. Instead of adding individual images to Xcode's file organizer, you add assets neatly organized in a single catalog.
As of iOS 8, you can now use [UIImage imageNamed:inBundle:compatibleWithTraitCollection:]
to load images by name from a different bundle. For example, a dynamic framework can use its own asset catalog separate from the main app's bundle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With