取得螢幕尺寸 (screen.size)
聲明
屏寬, 屏高 = screen.size()
回傳值
- 屏寬 整數型
- 屏高 整數型
說明
該函式的回傳值不受目前裝置的桌面或應用的橫直向狀態影響,也不受放大模式影響
該函式可在 XUI 中使用
範例
-- 根據分辨率判斷設備類型
width, height = screen.size()
if width == 640 and height == 1136 then
-- iPhone 5, 5S, iPod touch 5
elseif width == 640 and height == 960 then
-- iPhone 4, 4S, iPod touch 4
elseif width == 750 and height == 1334 then
-- iPhone 6, 6S, 7, 8
elseif width == 1242 and height == 2208 then
-- iPhone 6+, 6S+, 7+, 8+
elseif width == 768 and height == 1024 then
-- iPad 1, 2, mini 1
elseif width == 1536 and height == 2048 then
-- iPad 3, 4, 5, mini 2
elseif width == 320 and height == 480 then
-- iPhone 3GS / iPhone 4(僅作完整性列出,XXTouch 不支持如此老舊的設備)
end