【问题标题】:I need some information about @2x UIImageViews我需要一些关于@2x UIImageViews 的信息
【发布时间】:2023-03-29 04:01:01
【问题描述】:

只是想知道,我必须如何使用它?

我只需要在图像名称后设置@2x 吗?或者把它放在一个特定的文件夹中?还是别的什么?

感谢您的建议

【问题讨论】:

    标签: iphone ios uiimageview retina-display


    【解决方案1】:

    就在文件名之后。例如命名你的splash 320x480 default.png 然后你的640x960 default@2x.png

    【讨论】:

    • 感谢您的回答:)
    【解决方案2】:

    您需要做的就是在您的项目中添加第二张图片,其名称与原始图片相同,大小正好是原来的两倍,在扩展名之前的文件名末尾加上 @2x。

    例子:

    some-picture.png 为 20x40 像素

    some-picture@2x.png 为 40x80 像素

    无论何时使用imageNamed: 方法,只需传递原始名称,如[UIImage imageNamed:@"some-picture.png"]

    使用 Interface Builder 时也是如此。

    它会在运行时自动选择正确的。

    【讨论】:

    • 如果能显示640x960px,iOS设备会默认选择它,对吧?
    【解决方案3】:

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-25
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多