Obter as dimensões da tela (screen.size)
Declaração
largura_da_tela, altura_da_tela = screen.size()
Valores retornados
- largura da tela: inteiro
- altura da tela: inteiro
Observações
Os valores retornados por esta função não são afetados pelo estado vertical ou horizontal da mesa ou do aplicativo no dispositivo atual, nem pelo modo ampliado.
Esta função pode ser usada no XUI.
Exemplo
-- identifica o dispositivo pela resolução
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 (listado apenas para completude; o XXTouch não é compatível com dispositivos tão antigos)
end