sencha touch 模仿tabpanel導航欄TabBar的實例代碼
更新時間:2013年10月24日 16:17:11 作者:
這篇文章介紹了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();
//監(jiān)聽按鈕點擊事件
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
*執(zhí)行添加項,調(diào)用add方法后自動執(zhí)行
*/
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: '問卷調(diào)查',
//只有第一個設(shè)置的屬性有效
selected: true
},
{
xtype: 'button',
text: '我的積分'
},
{
xtype: 'button',
text: '開獎大廳'
},
{
xtype: 'button',
text: '幸運號碼'
},
{
xtype: 'button',
text: '更多'
}]
}
});
效果圖:
您可能感興趣的文章:
相關(guān)文章
js實現(xiàn)鼠標拖動圖片并兼容IE/FF火狐/谷歌等主流瀏覽器
js實現(xiàn)鼠標拖動圖片做了兼容IE,F(xiàn)F火狐,谷歌等主流瀏覽器,具體實現(xiàn)代碼如下,感興趣的朋友可以參考下哈,希望對你有所幫助2013-06-06js彈出層包含flash 不能關(guān)閉隱藏的2種處理方法
js彈出層包含flash 不能關(guān)閉隱藏的2種處理方法,需要的朋友可以參考一下2013-06-06nuxt+axios實現(xiàn)打包后動態(tài)修改請求地址的方法
這篇文章主要介紹了nuxt+axios實現(xiàn)打包后動態(tài)修改請求地址的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-04-04JS根據(jù)瀏覽器窗口大小實時動態(tài)改變網(wǎng)頁文字大小的方法
這篇文章主要介紹了JS根據(jù)瀏覽器窗口大小實時動態(tài)改變網(wǎng)頁文字大小的方法,涉及JavaScript針對頁面寬高的動態(tài)獲取與元素樣式動態(tài)運算的相關(guān)技巧,需要的朋友可以參考下2016-02-02