cocos2d-lua3.7控件篇(五)-PageView demo
PageVIew实现翻页的效果
使用cocos2d-lua社区版
local MainScene = class("MainScene", function()
return display.newScene("MainScene")
end)
function MainScene:ctor()
local layer = cc.LayerColor:create(cc.c4b(155, 155, 155, 255))
layer:addTo(self)
self:createUIPageView()
end
function MainScene:createUIPageView()
local page = ccui.PageView:create()
page:setContentSize(800,400)
for i = 1 , 18 do
local layout=ccui.Layout:create()
layout:setPosition(10,30*i)
print("test")
layout:setContentSize(cc.size(100,100))
local lbl3 = cc.Label:create()
lbl3:setString("-----------"..i)
lbl3:setContentSize(cc.size(100,100))
lbl3:setPosition(10,200)
layout:addChild(lbl3)
local lbl4 = cc.Label:create()
lbl4:setString("aaaaaaaaaaaa"..i)
lbl4:setContentSize(cc.size(100,100))
lbl4:setPosition(10,230)
layout:addChild(lbl4)
page:addPage(layout)---一个layout 为一个 page内容
end
page:addTo(self)
end
function MainScene:onEnter()
end
function MainScene:onExit()
end
return MainScene