按组区分资产目录中的图像 [英] Differentiating images in an asset catalog by their group

查看:70
本文介绍了按组区分资产目录中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用资产目录组有效地对具有共享名称的多个图像进行命名空间?

Is there any way to use asset catalog groups to effectively namespace multiple images with a shared name?

例如,如果我有多个名为Foo的图像处于不同的组中,是否可以使用imageNamed:指定要使用哪个图像(即类似UIImage(named:"Group1.Foo")的图像).

For example, if I have multiple images named Foo that are in different groups, is there a way to specify which one I would like with imageNamed: (i.e. something like UIImage(named:"Group1.Foo")).

很明显,我可以为所有图像自己创建唯一的名称,但是如果有一种方法可以利用群组为我做的话,那就太好了.

Obviously I could create unique names myself for all images, but it would be nice if there was a way to leverage groups to do it for me.

推荐答案

在资产目录中选择要为其添加名称空间的每个文件夹.转到文件夹属性,然后在名称提供名称空间"下选择.这应该为最终资产目录正确设置子目录.

Select each folder in your asset catalog that you'd like to add a namespace for. Go to the folder attributes and select under the name "Provides Namespace". This should properly set sub-directories for your final asset catalog.

您可以通过编辑每个文件夹的Contents.json来手动执行此操作.您将使用正确的格式添加以下内容.

You can do this manually by editing each folder's Contents.json. You would add the following with proper formatting.

"properties" : {
      "provides-namespace" : true
}

这篇关于按组区分资产目录中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆