【发布时间】:2023-03-29 04:01:01
【问题描述】:
只是想知道,我必须如何使用它?
我只需要在图像名称后设置@2x 吗?或者把它放在一个特定的文件夹中?还是别的什么?
感谢您的建议
【问题讨论】:
标签: iphone ios uiimageview retina-display
只是想知道,我必须如何使用它?
我只需要在图像名称后设置@2x 吗?或者把它放在一个特定的文件夹中?还是别的什么?
感谢您的建议
【问题讨论】:
标签: iphone ios uiimageview retina-display
就在文件名之后。例如命名你的splash 320x480 default.png 然后你的640x960 default@2x.png
【讨论】:
您需要做的就是在您的项目中添加第二张图片,其名称与原始图片相同,大小正好是原来的两倍,在扩展名之前的文件名末尾加上 @2x。
例子:
some-picture.png 为 20x40 像素
some-picture@2x.png 为 40x80 像素
无论何时使用imageNamed: 方法,只需传递原始名称,如[UIImage imageNamed:@"some-picture.png"]
使用 Interface Builder 时也是如此。
它会在运行时自动选择正确的。
【讨论】:
I just answered another question along these same lines.
Apple 实际上在 "Updating Your Image Resource Files" section of this iOS Drawing reference guide 中详细描述了预期的文件名。
具体来说,在文档中查找这些行:
Standard: <ImageName><device_modifier>.<filename_extension>
High resolution: <ImageName>@2x<device_modifier>.<filename_extension>
【讨论】: