Class

View

所有UI容器类的基类,容器类,继承自-> BaseView


方法

ID API 参数 返回值 平台 备注
1 onShow v: LuaFunction v - 显示监听
2 onHide v: LuaFunction v - 隐藏监听
3 onBack v: LuaFunction v - 返回按钮监听
4 onLayout v: LuaFunction v - 布局监听
5 addView v: View - - 添加子View
6 removeView v: View - - 移除子View
7 removeAllViews - - - 移除所有子View
8 children v: LuaFunction - - 子View构造函数
9 flexChildren v: View[] - - Flexbox 设置childViews

示例

onShow

view:onShow(function()
    print("i am show")
end)

onHide

view:onHide(function()
    print("i am hide")
end)

onBack

view:onBack(function()
    print("back pressed")
end)

onLayout

view:onLayout(function()
    print("i am layouted")
end)

addView

child = View()
parent = View()
parent:addView(child)

removeView

child = View()
parent = View()
parent:addView(child)
parent:removeView(child)

removeAllViews

child = View()
parent = View()
parent:addView(child)
parent:removeAllViews()

children

parent.children(function(parent) -- 所有在函数里创建的View都会被自动添加到parent里
    view = View()
    ...
end)

flexChildren

child1 = View()
child2 = View()
parent = View()
parent:flexChildren(child1, child2)

results matching ""

    No results matching ""