iosiphonexcodemacosxcasset

Is that possible to load a color from an external xcassets?


What I mean is this. I am creating a lot of color schemes to use.

All schemes are like themes for objects. For example, colors for text labels, background colors for elements, etc. So, my idea was to create different .xcassets. All .xcassets would have the colors with the same name. I switch the .xcassets and the colors change.

Is there a way to do that?


Solution

  • You cannot specify an asset catalog by name. But you can specify an asset by bundle. So you can use multiple bundles and multiple asset catalogs, one catalog per bundle. Each asset catalog in a bundle is your “external” asset catalog.

    However, I would suggest using instead the power of folders as namespaces inside one asset catalog: that way you can specify colors by names like "Theme1/red" vs "Theme2/red" and so on.