简体   繁体   English

将许多图像添加到xcodes资产目录 - 如何管理命名以及每个1x,2x,3x?

[英]Add many images to xcodes asset catalog - how to manage naming and 1x,2x,3x for each?

I have an app where I would like to add many images (500+) to xcode's asset catalog. 我有一个应用程序,我想在xcode的资产目录中添加许多图像(500+)。 Adding the 1x images was easy, I simply had to drag the first folder. 添加1x图像很简单,我只需要拖动第一个文件夹。 However to add the 2x and 3x images it seems I would need to drag each image in manually, and I'd prefer not to do that. 然而,要添加2x和3x图像,我似乎需要手动拖动每个图像,我宁愿不这样做。 The 3 different sizes for each image are all named the same, w/ just different sizes. 每个图像的3种不同尺寸都是相同的,只有不同的尺寸。 Is there anyway to automate this process? 反正有自动化这个过程吗?

You can named image something like : yourimg.png, yourimg@2x.png, yourimg@3x.png ,so it's become one set. 您可以将图像命名为: yourimg.png, yourimg@2x.png, yourimg@3x.png ,这样它就变成了一组。 Let's take another : dogImg.png, dogImg@2x.png, dogImg@3x.png then this is second set. 让我们拿另一个: dogImg.png, dogImg@2x.png, dogImg@3x.png然后这是第二集。

So, you can name images like this and put every images to one single folder. 因此,您可以命名这样的图像并将每个图像放在一个文件夹中。

Then you simply drag and drop that folder to xcode, and you have done! 然后你只需将该文件夹拖放到xcode,就完成了!

No need to use assets in this case! 在这种情况下无需使用资产! this naming conversion manage same as assetts .! 此命名转换与assetts管理相同。

Refer Raywebderlich's one tutorial 's portion where they are adding images like this. 请参阅Raywebderlich的一个教程部分,他们将添加这样的图像。

OR (recommended way - because it is using assets) 或(推荐方式 - 因为它使用资产)

Name your images like - test@1x.png, test@2x.png, test@3x.png and drag all them in to the assets and it will automatically take place at proper location. 将您的图像命名为 - test@1x.png, test@2x.png, test@3x.png并将它们全部拖入资产,它将自动在适当的位置进行。 That's it!! 而已!!

You can maintain folder structure also. 您也可以维护文件夹结构。 For example If you have folder structure like below screen shot, 例如,如果您有像下面屏幕截图那样的文件夹结构,

在此输入图像描述

and If you drag and drop whole Images folder to assets then xcode will manage everything for you(see result in below screenshot) but you just need to keep in mind that follow the naming standard for the images like test@1x.png, test@2x.png, test@3x.png . 如果您将整个Images文件夹拖放到资源,那么xcode将为您管理所有内容(请参阅下面的屏幕截图中的结果),但您只需要记住遵循图像的命名标准,如test@1x.png, test@2x.png, test@3x.png You can ignore @ for 1x image, I mean your image set can be like test.png, test@2x.png, test@3x.png also! 你可以忽略@ for 1x image,我的意思是你的图像集也可以像test.png, test@2x.png, test@3x.png @ test.png, test@2x.png, test@3x.png

Screenshot of assets after dragging Images from the finder, 从finder中拖动Images后的assets截图,

在此输入图像描述

Happyxcasset is a python script that easily imports resource files into xcassets in Xcode. Happyxcasset是一个python脚本,可以轻松地将资源文件导入Xcode中的xcassets。 https://github.com/qdvictory/happyxcasset You will like it. https://github.com/qdvictory/happyxcasset你会喜欢它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM