quick coocs 3.3final UIPageView不能缩放的处理方法

27 篇文章 0 订阅

对其父节点进行缩放,对UIPageView本身进行反缩放,再对其item进行缩放,对其显示区域进行缩放

local rate=0.5
    local node=cc.Node:create()
    self:addChild(node,10)
    node:setPosition(cc.p(100,100))

    self.pv = cc.ui.UIPageView.new {
    viewRect = cc.rect(0, 0, 250*3*rate, 150*3*rate),--显示区域
    column = 3, row = 3,--行列数
    -- padding = {left = 10, right = 10, top = 20, bottom = 20},--每个cell的间距
    columnSpace = 0, rowSpace = 0}--不知道这俩干啥的
    -- :onTouch(handler(self, self.touchListener))
    :addTo(node)
    node:setScale(rate)

    -- add items
    for i=1,36 do
        local item = self.pv:newItem()
        local content
        local lb = cc.ui.UILabel.new(
                    {text = "item"..i,
                    size = 20,
                    align = cc.ui.TEXT_ALIGN_CENTER,
                    color = display.COLOR_BLACK})
        content = cc.LayerColor:create(
            cc.c4b(math.random(250),
                math.random(250),
                math.random(250),
                250))
        lb:addTo(content,10)
        lb:pos(50,50)
        content:setContentSize(240*rate, 140*rate)
        content:setTouchEnabled(false)
        item:addChild(content)
        self.pv:addItem(item)        
    end
    self.pv:reload()
    
    self.pv:setScale(1/rate)
    cc.ui.UIPushButton.new("button.png")
    :pos(display.right-100,100)
    :onButtonClicked(function()
        table.remove(self.pv.items_,1)
        self.pv:reload()
    end)
    :addTo(self)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值