引用资产目录中文件夹中的图像 [英] Referencing image in a folder in asset catalog

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

问题描述

您可以在资产目录中创建文件夹.

In an asset catalog you can create folders.

在文件夹中,所有图像名称必须唯一.

Inside the folders all the image names have to be unique.

如果您有一个名为myImage的图像,并且尝试命名另一个图像myImage,则它将自动重命名为myImage-1.

If you have an image called myImage and you try to name another image myImage then it will automatically get renamed to myImage-1.

但是如果您有两个文件夹,则可以在不同的文件夹中拥有相同名称的图像.

But if you have two folders then you can have images with the same name in different folders.

那么,必须有一种引用这些方法的方法吗?

So, there must be a way to reference these?

有人知道如何通过资产目录中的文件夹和图像名称引用图像吗?

Does anyone know how to reference an image by the folder and image name inside the asset catalog?

推荐答案

我花了很多时间,但最终弄明白了. 在此处回答.复制如下.

I spent a ton of time but finally figured this out. Answered here. Copied below.

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

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天全站免登陆