화면 크기 가져오기 (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