作者vcore (vcore)
看板MacDev
标题[闲聊] iPhone6/6+萤幕大小笔记
时间Wed Sep 10 15:47:20 2014
底下是小弟个人心得,有疏漏烦请指正
==原生解析度==
iPhone3GS: 480x320 (163ppi)
iPhone5: 1136x640 (326ppi)
iPhone6: 1334x750 (326ppi)
iPhone6+: 1920x1080 (401ppi)
(ppi=pixels per inch)
但是对於开发者来说,程式里面得到的萤幕大小(虚拟座标系)是
==虚拟座标系==
iPhone5: 568x320 (实际大小1136x640 points,scale=2.0)
iPhone6: 667x375 (实际大小1334x750 points,scale=2.0)
iPhone6+: 736x414 (实际大小2208x1242 points,scale=3.0)
对开发者来说,UIImage载入的图片档的suffix有差异
(1) 在iPhone6上使用的仍然是
[email protected]之类的suffix name。(ppi与前代相同)
(2) 但是在iPhone6+上使用的是
[email protected]的suffix name
注: 401ppi的iPhone6+是iPhone3GS 163ppi的2.46倍,但是可能是为了命名考量
Apple选择的是@3x的大小,也就是图档在萤幕上显示时将会被缩小2.46/3=0.82倍
==Launch image==
在iPhone6上的实际尺寸为: 1334x750
在iPhone6+上的实际尺寸为: 2208x1242
Launch image实际在iPhone6+萤幕上显示时,
将会被缩放到1920x1080的大小(缩小为原尺
寸的0.869倍)
Q:在程式中如何得知目前装置的萤幕大小是多大?
iOS8引进了两个新的API, nativeScale与nativeBounds
可以得知实际的萤幕大小
CGRect rect = [[UIScreen mainScreen] nativeBounds];
iPhone6上将会得到1334x750的大小
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.224.61.194
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MacDev/M.1410335244.A.A10.html
※ 编辑: vcore (61.224.61.194), 09/10/2014 15:48:20
1F:→ manlike: 怎麽变成这样了 0.0 09/10 15:50
2F:→ vcore: 不好意思,前一篇有笔误! 实际上原有4寸app可以fit新大萤幕 09/10 15:51
3F:→ vcore: 但是会变成是放大的模式。 09/10 15:51
4F:→ vcore: 若透过[UIScreen mainScreen] bounds] 09/10 15:52
5F:→ vcore: 在iPhone6,6+上得到的会是不同的结果(667x375与736x414) 09/10 15:53
6F:推 elver: 我用xcode5 GM版 跑上面的模拟器 和你的有出入耶~ 09/11 11:49
7F:→ elver: [[UIScreen mainScreen]bounds] 09/11 11:50
8F:→ elver: 5s=>320x568 6=>320x568 6+=>320x568 09/11 11:51
9F:→ elver: -------------------------------------- 09/11 11:51
10F:→ elver: [[UIScreen mainScreen] nativeBounds] 09/11 11:52
11F:→ elver: 5x=>640x1136 6=>640x113 6+=>960x1704 09/11 11:55
12F:→ elver: ^6 09/11 11:55
13F:→ elver: -------------------------------------- 09/11 11:57
14F:→ elver: [[UIScreen mainScreen] nativeScale] 09/11 11:57
15F:→ elver: 5s=>2.00 6=>2.00 6+=>3.00 09/11 11:58
16F:推 elver: 打太快 xcode6 GM版 >_< 09/11 12:06
17F:→ vcore: 我也是GM版 请问您Launch image有加入吗? 09/11 16:14
18F:→ vcore: 要加入新的launch image,才不会以放大的模式执行 09/11 17:09
19F:推 elver: ~~~!!? 我没加Launch image 09/18 08:52