这篇文章介绍了sencha touch 模仿tabpanel导航栏TabBar的实例代码,有需要的朋友可以参考一下

基于sencha touch 2.2所写

效果图:

代码:

/*

*模仿tabpanel导航栏

*/

Ext.define('ux.TabBar', {

    alternateClassName: 'tabBar',

    extend: 'Ext.Toolbar',

    xtype: 'tabBar',

    config: {

        docked: 'bottom',

        cls: 'navToolbar',

        layout: {

            align: 'stretch'

        },

        defaults: {

            flex: 1

        },

        //被选中的按钮

        selectButton: null

    },

    initialize: function () {

        var me = this;

        me.callParent();

        //监听按钮点击事件

        me.on({

            delegate: '> button',

            scope: me,

            tap: 'onButtonTap'

        });

    },

    //更新被选中按钮

    updateSelectButton: function (newItem, oldItem) {

        console.log(oldItem);

        if (oldItem) {

            oldItem.removeCls('x-tabBar-pressing');

        }

        if (newItem) {

            newItem.addCls('x-tabBar-pressing');

        }

    },

    //当按钮被点击时

    onButtonTap: function (button) {

        this.setSelectButton(button);

    },

    /**

    * @private

    *执行添加项,调用add方法后自动执行

    */

    onItemAdd: function (item, index) {

        if (!this.getSelectButton() && item.getInitialConfig('selected')) {

            this.setSelectButton(item);

        }

        this.callParent(arguments);

    }

});

需要的css:

复制代码 代码如下:

.navToolbar {

    padding:0;

}

.navToolbar .x-button {

    border:0;

    margin:0;

    border-right:1px solid #585B5B;

    border-radius:0;

    padding:0;

}

.navToolbar .x-button .x-button-label {

    font-weight:normal;

    color:White;

    font-size:0.6em;

}

.navToolbar .x-tabBar-pressing {

    background-image:none;

    background-color:#0f517e;

    background-image:-webkit-gradient(linear,50% 0%,50% 100%,color-stop(0%,#0a3351),color-stop(10%,#0c4267),color-stop(65%,#0f517e),color-stop(100%,#0f5280));

    background-image:-webkit-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);

    background-image:-moz-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);

    background-image:-o-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);

    background-image:linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);

}

使用:

复制代码 代码如下:

Ext.define('app.view.MyBar', {

    alternateClassName: 'myBar',

    extend: 'ux.TabBar',

    xtype: 'myBar',

    config: {

        items: [

        {

            xtype: 'button',

            text: '问卷调查',

            //只有第一个设置的属性有效

            selected: true

        },

        {

            xtype: 'button',

            text: '我的积分'

        },

        {

            xtype: 'button',

            text: '开奖大厅'

        },

        {

            xtype: 'button',

            text: '幸运号码'

        },

        {

            xtype: 'button',

            text: '更多'

        }]

    }

});

sencha touch 模仿tabpanel导航栏TabBar的实现代码的更多相关文章

  1. sencha touch 模仿tabpanel导航栏TabBar(2013-11-7)

    基于sencha touch 2.2所写 代码: /* *模仿tabpanel导航栏 */ Ext.define('ux.TabBar', { alternateClassName: 'tabBar' ...

  2. iOS开发之 -- 判断tableview/scrollview的滑动方法,及导航栏渐变的实现代码

    开发的过程中,肯定会用到在视图想上滑动的时候,在导航处做一些操作,比如向上滑动的时候,做个动画,出现一个搜索框,或者其他的操作,那么我们怎么来判断它的滑动方向呢? 首先我们应该知道tableview继 ...

  3. jquery侧边折叠导航栏制作,两行代码搞定

    jquery侧边折叠导航栏制作,两行代码搞定 //CSS*{margin: 0;padding: 0} ul{list-style: none} .menu li ul{display: none} ...

  4. sencha touch 2 tabpanel中List的不显示问题,解决方案

    笔者在做sencha项目的时候碰到一个需求,就是"好友列表"中分为"未确认好友"和"已确认好友",两个都是一个list,自然想到的就是使用t ...

  5. 小程序 - 底部导航栏“tabBar”

    小程序底部导航 1.app.json页面配置: { "pages": [ "pages/movie/movie", "pages/cinema/cin ...

  6. 添加底部导航栏tabbar

    效果图: 如果要添加底部导航栏,最少2个,最多5个. app.json { "pages": [ "pages/index/index", "page ...

  7. 网页导航栏 html + css的代码实现

    一般来讲,我们的网页导航栏是这么个模式来构建在结构上:1.首先我们需要给导航栏的div 给个类名 一般为nav2.然后就是一个无序表格 3.由于导航栏的文字一般都是链接用来跳转页面 要在li里面包含一 ...

  8. <iOS 导航栏>第一节:导航栏透明方法实现代码

      说下导航栏的透明方法:   很多应用需要导航栏随着向上滑动,逐渐从透明变成不透明,很炫酷,大部分应用都在使用导航栏渐变效果,现附上代码然后直接将实现,一会讲下如何来实现,这一部分直接上代码.   ...

  9. 01 uni-app框架学习:项目创建及底部导航栏tabBar配置

    1.创建一个项目类型选择uniapp 2. pages里新建3个页面如下 3.在pages.json中配置底部导航tabBar 效果展示:

随机推荐

  1. linux c fprintf()

    #include<stdio.h> #include<unistd.h> #include<time.h> int main(int argc,char *argv ...

  2. LeetCode:16. 3Sum Closest(Medium)

    1. 原题链接 https://leetcode.com/problems/3sum-closest/description/ 2. 题目要求 数组S = nums[n]包含n个整数,找出S中三个整数 ...

  3. http报文和浏览器缓存机制

    目录 1. 请求报文 1.1请求行 1.2 请求头 一些常用的请求头信息 2. 响应报文 2.1 状态行 1> 响应状态码 2> 常见的响应状态码 2.2 响应头 3. 浏览器缓存 3.1 ...

  4. 30分钟玩转css3动画, transition,animation

    其实css3动画是就是2种实现,一种是transition,另一种就是animation.transition实现的话就是只能定制开始帧,和结束2帧:而animation实现的话可以写很多关键帧.没有 ...

  5. spring 读取properties文件--通过注解方式

    问题: 需要通过properties读取页面的所需楼盘的名称.为了以后便于修改. 解决: 可以通过spring的 PropertiesFactoryBean 读取properties属性,就不需要自己 ...

  6. selenide UI自动化进阶二 pageObject实现页面管理

    首先定义登录页面,上代码吧 LoginPage.java package com.test.selenium.page; import org.openqa.selenium.By; import s ...

  7. iFIERO - (二)宇宙大战 Space Battle -- SpriteKit 无限循环背景Endless、SpriteKit物理碰撞、CoreMotion加速计

    本节主要讲解如何创建无限循环Endless的星空背景(如下图).玩家飞船发射子弹,监测子弹击外星敌机的SpriteKit物理碰撞并消灭敌机,以及应用iOS的CoreMotion加速计移动飞船躲避外星敌 ...

  8. Django源码分析之执行入口

    魔法门 一般我们启动django,最简单的方法是进入project 目录,这时目录结构是这样的 然后我们执行python manage.py runserver,程序就开始执行了. 那django是如 ...

  9. 相关系数之杰卡德相似系数(Jaccardsimilarity coefficient)

    杰卡德相似系数(Jaccardsimilarity coefficient) (1)杰卡德相似系数 两个集合A和B交集元素的个数在A.B并集中所占的比例,称为这两个集合的杰卡德系数,用符号 J(A,B ...

  10. HDU 4433 locker(DP)(2012 Asia Tianjin Regional Contest)

    Problem Description A password locker with N digits, each digit can be rotated to 0-9 circularly.You ...