Ios 需要关于不同分辨率iPhone的图像资产的建议吗
我需要一个关于如何在不同分辨率的iPhone中使用图像的建议 正如我们所知,对于iPhone3gs和iPhone4,我们需要@1x图像 对于iPhone4s和iPhone5,6,我们需要@2x图像 对于iPhone 6+我们需要@3x图像 我正在考虑以两种方式添加图像资产 方式1-Ios 需要关于不同分辨率iPhone的图像资产的建议吗,ios,objective-c,xcode,screen-resolution,Ios,Objective C,Xcode,Screen Resolution,我需要一个关于如何在不同分辨率的iPhone中使用图像的建议 正如我们所知,对于iPhone3gs和iPhone4,我们需要@1x图像 对于iPhone4s和iPhone5,6,我们需要@2x图像 对于iPhone 6+我们需要@3x图像 我正在考虑以两种方式添加图像资产 方式1- abc.png size 20X20 abc@2x.png size 40X40 abc@3x.png size 60X60 abc.png size 20X
abc.png size 20X20
abc@2x.png size 40X40
abc@3x.png size 60X60
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"];
}
在访问我们使用的图像时
UIImage *img = [UIImage imageNamed:@"abc.png"];
在非视网膜显示中,ios将自动拾取abc.png
对于iPhone4S,它将选择5,6abc@2x.png自动地
对于iphone6+来说,它会选择abc@3x.png自动地
方式2-
abc.png size 20X20
abc@2x.png size 40X40
abc@3x.png size 60X60
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或者我应该为每个分辨率使用单独的视网膜和非视网膜图像
谢谢使用哪种方法取决于您的需要: 当您需要在所有设备中显示相同大小的图标时,请使用方法一,这是最好的方法 当需要为不同的屏幕大小显示不同大小的图标时,请使用方法2
如果你的要求是使用方法二,那么考虑以下几点:
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
您应该使用第一种方法,您不需要if语句。让iPhone为您完成工作。这就是命名约定的目的。使用第一种方法。大小不一定是成比例的,但通常是成比例的。此外,如果您只支持iOS7,您可以只管理一个xcassets文件。