PageVIew实现翻页的效果

cocos2d-lua3.7控件篇(五)-PageView demo

使用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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
  • 2021-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-06-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案