适用于iPhone 6和iPhone 6+的原生分辨率验证

时间:2014-12-04 16:56:43

标签: ios objective-c screen-resolution iphone-6 iphone-6-plus

尝试在iPhone 6和6+的模拟器中以原始分辨率运行。我正在使用Xcode 6。

以适当的分辨率在XCode中完成了启动映像安装。

iPhone 6(Retina HD 4.7)需要750 x 1334的纵向启动图像。

iPhone 6 Plus(Retina HD 5.5)需要分别为1242 x 2208和2208 x 1242的纵向和横向图像。

但在代码中,

[[UIScreen mainScreen] bounds].size.width
[[UIScreen mainScreen] bounds].size.height

获取

375.000000, 667.000000 for iphone 6 simulator
414.000000, 736.000000 for iphone 6+ simulator

如果删除图像,请

 320.000000, 568.000000 for iphone 6 simulator
 320.000000, 568.000000 for iphone 6+ simulator

所以我猜最高数字验证我们处于高分辨率模式,但为什么我们没有得到真正的屏幕分辨率? iphone 6是/ 2和iphone 6+ / 3.或者这只是设计。

[ADDITION]

以为我会添加此脚本以获取有关如何生成所有XCODE 6启动屏幕的示例....

必须安装ImageMagick,使用没有alpha图层的源文件。

convert black.png -resize 1024x768!  Launch-iPad-1024x768-Landscape-ios-5-6-1x.png
convert black.png -resize 1024x768!  Launch-iPad-1024x768-Landscape-ios-7-8-1x.png
convert black.png -resize 1536x2048! Launch-iPad-1536x2048-Portrait-ios-5-6-2x.png
convert black.png -resize 1536x2048! Launch-iPad-1536x2048-Portrait-ios-7-8-2x.png
convert black.png -resize 2048x1536! Launch-iPad-2048x1536-Landscape-ios-5-6-2x.png
convert black.png -resize 2048x1536! Launch-iPad-2048x1536-Landscape-ios-7-8-2x.png
convert black.png -resize 768x1024!  Launch-iPad-768x1024-Portrait-ios-5-6-1x.png
convert black.png -resize 768x1024!  Launch-iPad-768x1024-Portrait-ios-7-8-1x.png
convert black.png -resize 1242x2208! Launch-iPhone-1242x2208-Portrait-ios-8-HD-5.5.png
convert black.png -resize 2208x1242! Launch-iPhone-2208x1242-Landscape-ios-8.png
convert black.png -resize 320x480!   Launch-iPhone-320x480-Portrait-ios-5-6-1x.png
convert black.png -resize 640x1136!  Launch-iPhone-640x1136-Portrait-ios-5-6-Retina-4.png
convert black.png -resize 640x1136!  Launch-iPhone-640x1136-Portrait-ios-7-8-Retina-4.png
convert black.png -resize 640x960!   Launch-iPhone-640x960-Portrait-ios-5-6-2x.png
convert black.png -resize 640x960!   Launch-iPhone-640x960-Portrait-ios-7-8-2x.png
convert black.png -resize 750x1334!  Launch-iPhone-750x1334-Portrait-ios-8-HD-4.7.png

1 个答案:

答案 0 :(得分:0)

如果正常,你可以使用[UIScreen mainScreen].nativeScale女巫将2.6f,如果在iPhone 6 plus上放大2.8f,或者使用已定义的宏:

#define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 568.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
#define IS_STANDARD_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0  && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale)
#define IS_ZOOMED_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale > [UIScreen mainScreen].scale)
#define IS_STANDARD_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_ZOOMED_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale < [UIScreen mainScreen].scale)

以下是If屏幕缩放的屏幕界限

<UIScreenMode: 0x17802f240; size = 1242.000000 x 2208.000000> // STANDARD
<UIScreenMode: 0x178226be0; size = 1125.000000 x 2001.000000> // ZOOMED