使用链接将〜ipad资源指向@ 2x资源 [英] Using links to point ~ipad resources to @2x resources

查看:47
本文介绍了使用链接将〜ipad资源指向@ 2x资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找解决方案,以解决复制数百个@2x文件仅重命名它们~ipad的问题.我尝试了许多想法,这些想法大多涉及在代码中进行.我会将自己发现的问题很好地发布为我自己的问题的答案:使用符号链接将~ipad指向@2x文件.

I've been looking for a solution to the issue of duplicating hundreds of @2x files only to rename them ~ipad. I tried a number of ideas which mostly involved doing it in code. I'll post as the answer to my own question what I found works well: Use symlinks to point ~ipad to @2x files.

我只想在此处记录它,因为我在搜索中没有看到此解决方案.

I just wanted to document it here as I have not seen this solution in my search.

推荐答案

诀窍是创建指向@2x文件的链接并为该链接命名~ipad.

The trick is to create a link to the @2x file and name that link ~ipad.

这不是在Finder中找到的别名"命令.

This is NOT the "Alias" command found in Finder.

手动使用终端并输入以下内容:

Manually you'd use the Terminal and enter something like this:

ln -s image@2x.png image~ipad.png

现在,当您运行代码时,在iPad上运行时,任何智能捕获设备适当文件的UIImage方法都将使用@2x文件.链接在磁盘上大约有16个字节,因此可以节省大量存储空间.

Now when you run your code any of the UIImage methods that intelligently grab a device appropriate file will use the @2x files when running on an iPad. Links are about 16 bytes on disk, so this saves a ton of storage.

我还编写了一个bash脚本来自动浏览目录,并为找到的每个@2x文件创建~ipad链接:

I also wrote a little bash script to automagically go through a directory and create ~ipad links for every @2x file it finds:

#! /bin/sh

# Script to batch create symlinks that point ~ipad files to @2X files

# To run:
# Copy to the directory where the files are located
# Enter the following at the terminal prompt:
# bash create_ipad_image_links.txt

# For every @2x file we find in this directory we create a symlink

for file in *@2x.png
do
  echo "link: ${file//@2x/~ipad} to: $file" 
  ln -s $file ${file//@2x/~ipad}
done

上面代码中的使用说明.如果可以通过任何方式对此进行改进,请发表评论.我确定有更好的方法(更流畅)来解决这个问题.

Usage instructions in the code above. Please comment if this can be improved in any way. I'm sure there are better (slicker?) ways to approach this.

这篇关于使用链接将〜ipad资源指向@ 2x资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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