简体   繁体   English

Xcode 11,暗/亮图像的资产目录命名约定?

[英]Xcode 11, Asset catalogue naming convention for dark / light images?

Previously images dragged into the Xcode asset catalogue could be named as follows...以前拖入 Xcode 资产目录的图像可以命名如下...

Rabbit@2x.png
Rabbit@3x.png 

on releasing the drag these images were automatically assigned to the correct 2x & 3x slots within the catalogue.在释放阻力时,这些图像会自动分配到目录中正确的2x3x插槽。

Now with iOS 13 and Xcode 11 we have the ability to add an alternate set of images for use in dark mode.现在有了 iOS 13 和 Xcode 11,我们能够添加一组备用图像以在暗模式下使用。 Does anyone know of if there is a way to specify light / dark as part of the filename so that images automatically end up the light and dark slots.有谁知道是否有办法将明/暗指定为文件名的一部分,以便图像自动结束明暗槽。

ie IE

Rabbit@2x.png
Rabbit@3x.png
Rabbit@2x.dark.png
Rabbit@3x.dark.png 

Previously images dragged into the Xcode asset catalogue could be named as follows之前拖入Xcode资产目录的图片可以命名如下

Yes, that's because those names were used, years ago, before there were asset catalogs, when the image files had to live in the app bundle itself.是的,那是因为这些名称是在几年前使用的,当时还没有资产目录,当时图像文件必须存在于应用程序包本身中。 There had to be a way to let the runtime know how the image was to be used, and those naming conventions were the only way.必须有一种方法让运行时知道如何使用图像,而这些命名约定是唯一的方法。 Nowadays, though, that's not needed;但是,现在不需要了。 the images can have any names, because they just go into slots of an Image Set.图像可以有任何名称,因为它们只是将 go 放入图像集的插槽中。 But Apple provides a shortcut so that you can easily switch from using the app bundle to using the asset catalog, thus coming into the modern world.但 Apple 提供了一个快捷方式,让您可以轻松地从使用 app bundle切换到使用资产目录,从而进入现代世界。

with iOS 13 and Xcode 11 we have the ability to add an alternate set of images for use in dark mode.通过 iOS 13 和 Xcode 11,我们能够添加一组备用图像以在暗模式下使用。 Does anyone know of if there is a way to specify light / dark as part of the filename so that images automatically end up the light and dark slots有谁知道是否有办法将亮/暗指定为文件名的一部分,以便图像自动结束亮和暗槽

Yes, there is no such way.是的,没有这样的方法。 Apple long ago stopped adding naming conventions for further distinctions among image files in the app bundle itself, because now the asset catalog exists and it has slots. Apple 很久以前就停止添加命名约定以进一步区分应用程序包本身的图像文件,因为现在资产目录存在并且它具有插槽。 So obviously there is no app bundle naming convention for light/dark mode, which just started existing.所以很明显,没有适用于明暗模式的应用程序包命名约定,它刚刚开始存在。 There is no need for a shortcut because you were never using a naming convention to begin with.不需要快捷方式,因为您从一开始就没有使用命名约定。 You don't need to come into the modern world because you're already in it.你不需要进入现代世界,因为你已经身处其中。 Just put the images in their slots.只需将图像放在它们的插槽中即可。 You can automate that process, but mere naming conventions is not the way.可以使该过程自动化,但仅靠命名约定不是办法。

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

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