如果我们想要使用此图像覆盖所有分辨率的屏幕的全宽和半高,那么最适合图像的尺寸是:background.png,background @ 2x.png和background@3x.png iPhone肖像应用?
这就是我们现在拥有的:
Device Points Pixels Scale Physical Pixels Physical PPI Size
iPhone X 812x375 2436x1125 3x 2436x1125 458 5.8"
iPhone 6 Plus 736x414 2208x1242 3x 1920x1080 401 5.5"
iPhone 6 667x375 1334x750 2x 1334x750 326 4.7"
iPhone 5 568x320 1136x640 2x 1136x640 326 4.0"
iPhone 4 480x320 960x640 2x 960x640 326 3.5"
iPhone 3GS 480x320 480x320 1x 480x320 163 3.5"
Run Code Online (Sandbox Code Playgroud)

有人说,对于iPhone 6 Plus,对于边缘到边缘的图像(如屏幕左下边缘的横幅),他们会准备back@3x.png,宽度为1242,iPhone 6为back@2x.png,宽度750以匹配iPhone 6的屏幕尺寸,但我不认为这是一个好主意,因为1242/3 = 414和750/2 = 375所以将它们命名为@ 2x和@ 3x没有意义.然后应该有什么宽度back.png - 375或414?
图形名称使用@ 2x和@ 3x后缀,因此如果例如image@3x.png具有30x30分辨率,则逻辑上认为image@2x.png应具有20x20分辨率,image.png应为10x10.这意味着如果我们想要为每个屏幕设置清晰的全宽图像,那么我们可能应该创建back@3x.png,宽度为414*3 = …
假设我想要一个捆绑的图像占用iPhone应用程序中所有可用的屏幕宽度 - 例如横幅.我想创建my_banner.png与宽度320px,my_banner@2x.png与宽度640px和my_banner@3x.png为iPhone 6加上与宽度1242px.但iPhone 6的分辨率是750×1334像素.仍然@2x与iPhone 4和5 共享后缀,具有640px宽度.
什么是推荐的方式或一个很好的方式来指定已经为优化的图像文件750px的宽度iPhone 6?好像它不能在一个asset catalog?它应该以编程方式完成吗?是否有其他后缀可用于iPhone 6?
我想为iPhone每个设备指定不同的背景图像.像这样
iPhone 6 Plus 1242x2208 pixels bg@3x.png
iPhone 6 750x1334 pixels bg@2x.png
iPhone 5 640x1136 pixels bg@2x.png
iPhone 4 640x960 pixels bg@2x.png
iPhone 3GS 320x480 pixels bg.png
Run Code Online (Sandbox Code Playgroud)
在LaunchImage没有可用于指定图像的选择Retina HD 4.7装置.所以启动图像没问题.

在.xcassets文件中,我有选择1x,2x,Retina 4 2x和3x.但是iPhone 6 (1334x750)设备没有选择.

那么如何1334x750 px为iPhone 6设备提供图像呢?寻找使用.xcassets文件的一些解决方案,而不是通过以编程方式为每个设备加载图像.
我已经访问了相关的SO的问题,但没有一个专门针对iPhone 6设备图像.
我已经看过各种关于图像尺寸的旧帖子,但我找不到任何最新信息,甚至不知道是否可以通过资产目录为所有iPad和iPhone屏幕尺寸提供图像.
这是我发现的最好的帖子,但在Xcode 7中它没有显示"Retina 4 2x"或iPhone 6/6+
在xcode 7中有一个通用选项,但这三个图像不支持所有设备大小.
我已经看过你可以在资产目录之外提供自己的图像的选项,但我真的很想使用资产目录.
如何为不同的iPhone/iPad使用xcassets /通用背景图像?
编辑:看起来我可能不得不去无资产目录路线:(
一个)
我希望将来证明这个解决方案,所以它会回落,如果需要,请调整最合适的图像,因为我不确定会发生什么.
NSNumber *screenWidth = @([UIScreen mainScreen].bounds.size.width);
NSString *imageName = [NSString stringWithFormat:@"name-%@w", screenWidth];
UIImage *image = [UIImage imageNamed:imageName];
Run Code Online (Sandbox Code Playgroud)
B)
或者这个代码可能更好?虽然我不确定它与哪种尺寸有关,但由于它不支持x3图像,它也有点过时了?
#import <UIKit/UIKit.h>
@interface UIImage (DefaultImage)
// uses statusbar orientation
+ (UIImage *)defaultImage;
//uses given orientation
+ (UIImage *)defaultImageForOrientation:(UIInterfaceOrientation)orient;
@end
Run Code Online (Sandbox Code Playgroud)
@implementation UIImage (DefaultImage)
+ (UIImage *)defaultImage {
return [self defaultImageForOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
}
+ (UIImage *)defaultImageForOrientation:(UIInterfaceOrientation)orient {
// choose the correct launch image for orientation, …Run Code Online (Sandbox Code Playgroud) 我为@ 2x @Retina 4和@ 3x设置了三个图像.

当我运行应用程序时,我得到以下结果.
iPhone 4s :twitter图片iPhone 5 : 谷歌图片iPhone 6+ :facebook图片.iPhone 6 :twitter图片一切都是好的.但是当我在iPhone 6上运行时它会拍摄推特图片,但它应该采用谷歌图像.
这是xcode的错误吗?
我已将启动图像设置在资产目录(LaunchImage)中,我也在Xcode的目标"常规"选项卡中设置了该目录.LaunchScreen运行应用程序时显示默认文件,但我读了这篇文章,我做了那里所说的:Launch Screen File在"常规"选项卡和.plist中都清空参数
但现在,我没有显示目录或默认的适当的启动图像,而是显示黑屏...
我只支持iPhone,iOS 7,8和9.
我能错过什么?
谢谢
编辑:这可能是因为图像尺寸不正确?例如,对于iPhone Portrait Retina HD 5.5,我有一个大小为1242 x 2208的文件和名称launch_iPhone6Plus-Portrait@3x.png,这是正确的吗?
ios ×6
iphone ×6
iphone-6 ×2
objective-c ×2
xcode ×2
cocoa-touch ×1
ios8 ×1
launchimage ×1
xcasset ×1
xcode6 ×1
xcode7 ×1