跳到主要内容

获取可见节点信息(nodeView.forVisible)

函数

节点信息 =  nodeView.forVisible()

返回值

  • 节点信息 文本型

说明

返回当前正在前台运行app 的所有可见节点信息

此方法只能在 3.0.0 以上版本中使用

示例

local drawViews = {}  -- 绘制对像存储 防止自动回收
local enumerationInfo --屏幕绘制函数
enumerationInfo = function (info)
local drawView = screenDraw.init(info.frame.x, info.frame.y, info.frame.width, info.frame.height, info.text and info.text or "")
table.insert(drawViews, drawView)
drawView:show()
if (type(info.subviews) == "table") then
for key, value in pairs(info.subviews) do
enumerationInfo(value)
end
end
end

local info = nodeView.forVisible() --获取可见的节点信息

for k,v in pairs(json.decode(info)) do --使用屏幕绘制函数 绘制出来
enumerationInfo(v)
end

sys.msleep(10000) -- 延迟等待 10000毫秒后结束脚本