【问题标题】:Need suggestion regarding images assets for different resolution of iPhone需要有关 iPhone 不同分辨率的图像资产的建议
【发布时间】:2015-02-20 14:50:22
【问题描述】:

我需要关于如何在不同分辨率的 iPhone 中使用图像的建议。

我们知道,对于 iPhone3gs 和 iPhone 4,我们需要@1x 图像。

对于 iPhone4s 和 iPhone 5,6,我们需要 @2x 图像。

对于 iPhone 6+,我们需要@3x 图片。

我正在考虑以两种方式添加图片资源。

方式 1 -

abc.png         size 20X20

abc@2x.png      size 40X40

abc@3x.png      size 60X60

在访问我们使用的图像时

UIImage *img = [UIImage imageNamed:@"abc.png"];

这里在非retina显示ios会自动选择abc.png 对于 iphone 4s,5,6 它会自动选择 abc@2x.png 对于 iphone6+,它会自动选择 abc@3x.png

方式 2 -

abc.png         size 20X20

abc@2x.png      size 40X40

abc_iphone5or6.png         size 25X25
size is bigger because resolution is big, we need to show big icon , if we use way 1 then it will show 20X20 size icon and will look smaller on big screens

abc_iphone5or6@2x.png      size 50X50 


abc_iphone6+.png         size 35X35 
size is bigger because resolution is big, we need to show big icon , if we use way 1 then it will show 20X20 size icon and will look smaller on big screens

abc_iphone6+@3x.png      size 70X70

if(is_iphone4or4s){
    UIImage *img = [UIImage imageNamed:@"abc.png"];
}
else of (iphone5or6){
   UIImage *img = [UIImage imageNamed:@"abc_iphone5or6.png"];
}
else{
    UIImage *img = [UIImage imageNamed:@"abc_iphone6+.png"];
}

请建议应该使用哪种方法。我应该只添加 abc.png、abc@2x.png 和 abc@3x.png 还是应该为每个分辨率使用单独的视网膜和非视网膜图像?

谢谢

【问题讨论】:

  • 你应该使用第一种方法,你不需要 if 语句。让 iPhone 为您完成工作。这就是命名约定的用途。
  • 使用第一种方法。大小不必成比例,但通常是成比例的。另外,如果你只支持 iOS 7,你可以只创建一个 xcassets 文件。

标签: ios objective-c xcode screen-resolution


【解决方案1】:

使用哪种方法取决于您的需要:

当您需要在所有设备上显示相同大小的图标时,请使用方法一,这是最好的方法。

当您需要为不同的屏幕尺寸显示不同尺寸的图标时,请使用方法二

如果您的要求是使用方法二,请考虑以下几点:

To Display icon of size 20X20 in iPhone4/4s

abc.png         size 20X20

abc@2x.png      size 40X40

To Display icon of 25X25 in iPhone5/6

abc_iphone5or6.png      size 50X50

To Display icon of size 35X35 in iPhone+

abc_iphone6Plus.png      size 70X70

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多