基于sencha touch 2.2所写

代码:

  1. /*
  2. *模仿tabpanel导航栏
  3. */
  4. Ext.define('ux.TabBar', {
  5. alternateClassName: 'tabBar',
  6. extend: 'Ext.Toolbar',
  7. xtype: 'tabBar',
  8. config: {
  9. docked: 'bottom',
  10. cls: 'navToolbar',
  11. layout: {
  12. align: 'stretch'
  13. },
  14. defaults: {
  15. flex: 1
  16. },
  17. //被选中的按钮
  18. selectButton: null
  19. },
  20. initialize: function () {
  21. var me = this;
  22. me.callParent();
  23. //监听按钮点击事件
  24. me.on({
  25. delegate: '> button',
  26. scope: me,
  27. tap: 'onButtonTap'
  28. });
  29. },
  30. //更新被选中按钮
  31. updateSelectButton: function (newItem, oldItem) {
  32. if (oldItem) {
  33. oldItem.removeCls('x-tabBar-pressing');
  34. }
  35. if (newItem) {
  36. newItem.addCls('x-tabBar-pressing');
  37. }
  38. },
  39. //当按钮被点击时
  40. onButtonTap: function (button) {
  41. if (!button.getInitialConfig('noSelect')) {
  42. this.setSelectButton(button);
  43. }
  44. },
  45. /**
  46. * @private
  47. *执行添加项,调用add方法后自动执行
  48. */
  49. onItemAdd: function (item, index) {
  50. if (!this.getSelectButton() && item.getInitialConfig('selected')) {
  51. this.setSelectButton(item);
  52. }
  53. this.callParent(arguments);
  54. }
  55. });

需要的css:

  1. .navToolbar {
  2. padding:;
  3. }
  4. .navToolbar .x-button {
  5. border:;
  6. margin:;
  7. border-right:1px solid #585B5B;
  8. border-radius:;
  9. padding:;
  10. }
  11. .navToolbar .x-button .x-button-label {
  12. font-weight:normal;
  13. color:White;
  14. font-size:0.6em;
  15. }
  16. .navToolbar .x-tabBar-pressing {
  17. background-image:none;
  18. background-color:#0f517e;
  19. 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));
  20. background-image:-webkit-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
  21. background-image:-moz-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
  22. background-image:-o-linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
  23. background-image:linear-gradient(top,#0a3351,#0c4267 10%,#0f517e 65%,#0f5280);
  24. }

使用:

  1. Ext.define('app.view.MyBar', {
  2. alternateClassName: 'myBar',
  3. extend: 'ux.TabBar',
  4. xtype: 'myBar',
  5. requires: ['app.view.About'],
  6. config: {
  7. items: [
  8. {
  9. xtype: 'button',
  10. text: '首页',
  11. //只有第一个设置的属性有效
  12. selected: true,
  13. action: 'redirect',
  14. redirect: 'home'
  15. },
  16. {
  17. xtype: 'button',
  18. text: '关于',
  19. action: 'redirect',
  20. redirect: 'about'
  21. },
  22. {
  23. xtype: 'button',
  24. text: '其他',
  25. //没有选中效果
  26. noSelect:true,
  27. action: 'other'
  28. }]
  29. }
  30. });

效果图:

2013.11.7

增加配置:没有选中效果

使用示例:

http://www.cnblogs.com/mlzs/p/3382229.html

sencha touch 模仿tabpanel导航栏TabBar(2013-11-7)的更多相关文章

  1. sencha touch 模仿tabpanel导航栏TabBar的实现代码

    这篇文章介绍了sencha touch 模仿tabpanel导航栏TabBar的实例代码,有需要的朋友可以参考一下 基于sencha touch 2.2所写 效果图: 代码: /* *模仿tabpan ...

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

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

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

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

  4. 添加底部导航栏tabbar

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

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

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

  6. 第一步 使用sencha touch cmd 4.0 创建项目、打包(加入全局变量、公用类、自定义扩展、资源文件)

    参考资料: http://www.cnblogs.com/qqloving/archive/2013/04/25/3043606.html http://www.admin10000.com/docu ...

  7. 微信小程序------导航栏样式、tabBar导航栏

    一:导航栏样式设置 小程序的导航栏样式在app.json中定义. 这里设置导航,背景黑色,文字白色,文字内容测试小程序 app.json内容: { "pages":[ " ...

  8. 微信小程序入门四: 导航栏样式、tabBar导航栏

    实例内容 导航栏样式设置 tabBar导航栏 实例一:导航栏样式设置 小程序的导航栏样式在app.json中定义. 这里设置导航,背景黑色,文字白色,文字内容测试小程序 app.json内容: { & ...

  9. Taro多端自定义导航栏Navbar+Tabbar实例

    运用Taro实现多端导航栏/tabbar实例 (H5 + 小程序 + React Native) 最近一直在捣鼓taro开发,虽说官网介绍支持编译到多端,但是网上大多数实例都是H5.小程序,很少有支持 ...

随机推荐

  1. Python:查看矩阵大小,查看列表大小

    对于Python3.5 查看矩阵大小 >>>import numpy as np >>>from numpy import random >>>m ...

  2. UNIX环境编程学习笔记(9)——文件I/O之文件访问权限的屏蔽和更改

    lienhua342014-09-10 1 文件访问权限 在文件访问权限和进程访问控制中,我们已经讲述过文件访问权限位,为了方便,我们重新列在下面, 表 1: 文件的 9 个访问权限位  st_mod ...

  3. Capability Model

    Data Scientist, Analytics We’re looking for data scientists to work on our core and business product ...

  4. Kafka配置说明

    Broker  Configs Property Default Description broker.id   每个broker都可以用一个唯一的非负整数id进行标识:这个id可以作为broker的 ...

  5. 图像中的artifacts

    artifacts 瑕疵 伪影(Artifacts) 伪影(Artifacts)-CT-基础术语 - 影像园 http://www.xctmr.com/baike/ct/c34b5413e305b45 ...

  6. MLE、MAP、贝叶斯三种估计框架

    三个不同的估计框架. MLE最大似然估计:根据训练数据,选取最优模型,预测.观测值D,training data:先验为P(θ). MAP最大后验估计:后验概率. Bayesian贝叶斯估计:综合模型 ...

  7. ab压测札记(Apache Bench)

    1 ab安装 ab实际上是apache httpd里面的一个工具或者说子模块,安装apache httpd可以参考另一篇文章JBOSS集群的2.3节 安装目录:/apache目录/bin/,如下 2 ...

  8. 7 -- Spring的基本用法 -- 12... Spring 3.0 提供的表达式语言(SpEL)

    7.12 Spring 3.0 提供的表达式语言(SpEL) Spring表达式语言(简称SpEL)是一种与JSP 2 的EL功能类似的表达式语言,它可以在运行时查询和操作对象图.支持方法调用和基本字 ...

  9. video标签 api

    video 设置及控制:http://www.w3school.com.cn/tags/html_ref_audio_video_dom.asp video 事件:http://www.w3schoo ...

  10. 【RF库Collections测试】Remove Duplicates

    Name:Remove DuplicatesSource:Collections <test library>Arguments:[ list_ ]Returns a list witho ...