外观
历史资料,不作为当前安装或接口合同
本页是 MonkeyKing iOS 历史参考,已做品牌与示例适配,并非原文逐字转载。文中的旧版本号、系统范围、收费授权、服务器、下载地址、XPP/XUI 及接口行为均属于历史引擎,不代表当前产品承诺。请先查阅当前模块支持表和开发流程。 来源、原作者署名与适配记录。图示为历史交互说明,并非当前应用截图;example.com 与示例邮箱需替换为自己的测试服务。
获取屏幕尺寸 (screen.size)
声明
lua
屏宽, 屏高 = screen.size()参数及返回值
- 屏宽 整数型
- 屏高 整数型
说明
这个函数的返回值不受当前设备的桌面或者应用的的横竖屏状态影响,也不受放大模式影响
这个函数可以在 XUI 中使用
示例
lua
-- 根据分辨率判断设备类型
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
-- 这个应该不可能
end