PageView的设置

1、创建一个PageView控件,自动生成background精灵和mask的view视图和indicator

View下面有一个content(Layout类型) ,content可以存放每页内容

页面指示器,可以清晰看当前是多少也

2、监听PageView事件

    // 监听事件

    onPageEvent (sender, eventType) {

        // 翻页事件

        if (eventType !== cc.PageView.EventType.PAGE_TURNING) {

            return;

        }

        console.log("当前所在的页面索引:" + sender.getCurrentPageIndex());

}

PageView控件的属性

    properties: {

        target: cc.PageView,

    },

this.target.setCurrentPageIndex(0)//设置当前在哪页

this.target.getCurrentPageIndex()//当前页的索引

this.target.scrollToPage(0);//滚动到哪页  第二个参数为滚动所需时间,默认值为 0.3 秒

this.target.addPage(this._createPage());//在最后页添加一页

this.target.insertPage(this._createPage(), this.target.getCurrentPageIndex());//在某页添加一页

this.target.getPages();//总共有多少页

this.target.removePage(pages[pages.length - 1]);//删除最后一页

this.target.removePageAtIndex(this.target.getCurrentPageIndex());//删除当前页

this.target.removeAllPages();//删除所有页

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值