Written based on sencha touch 2.2
Code:
/*
*Imitate tabpanel navigation bar
*/
Ext.define('ux.TabBar', {
alternateClassName: 'tabBar',
extend: 'Ext.Toolbar',
xtype: 'tabBar',
config : {
docked: 'bottom',
cls: 'navToolbar',
layout: {
align: 'stretch'
},
defaults: {
flex: 1
);
//Listen for button click events
me.on({
delegate: '> button',
scope: me,
tap: 'onButtonTap'
}) ;
},
//Update the selected button
updateSelectButton: function (newItem, oldItem) {
console.log(oldItem);
if (oldItem) {
oldItem. removeCls('x-tabBar-pressing');
}
if (newItem) {
} newItem.addCls('x-tabBar-pressing');
}
},
//When the button is clicked
onButtonTap: function (button) {
this.setSelectButton(button);
},
/**
* @private
* Execute the added item and automatically execute it after calling the add method
*/
onItemAdd: function (item, index) {
);
}
});
Required css:
Copy code
The code is as follows:
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);
}
Use:
Copy code
The code is as follows:
Ext.define('app.view.MyBar', {
alternateClassName: 'myBar',
extend: 'ux.TabBar',
xtype: 'myBar',
config: {
items: [
selected : true
xtype: 'button',
text: 'Lottery Hall'
},
{
xtype: 'button',
text: 'Lucky Number'
},
{
xtype: 'button ',
text: 'More'
}]
}
});
Rendering: