画面サイズを取得 (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