Custom tab bar in Titanium


// TAB 1

var tab1 = Ti.UI.createView({

height : ’30dp’,

width : ‘40.625%’,

top : ‘151dp’,

font : font2,

left : ‘9.375%’,

backgroundColor : “#146F15”,

borderColor : “#294f62”,

borderWidth : ‘1dp’,

borderRadius : ’10dp’,

});

var tab1Label = Ti.UI.createLabel({

text : ‘Km’,

color : “#FFFFFF”,

font : font2,

});

tab1.add(tab1Label);

win.add(tab1);

// TAB 2

// TAB 1

var tab2 = Ti.UI.createView({

height : ’30dp’,

width : ‘40.625%’,

top : ‘151dp’,

font : font2,

right : ‘9.375%’,

backgroundColor : “transparent”,

borderColor : “#294f62”,

borderWidth : ‘1dp’,

borderRadius : ’10dp’

});

var tab2Label = Ti.UI.createLabel({

text : ‘Miles’,

color : “#FFFFFF”,

font : font2,

});

tab2.add(tab2Label);

// ADD EVENT LISTENERS

tab1.addEventListener(‘click’, function() {

tab1.backgroundColor = “#146F15”;

tab1Label.color = “#FFFFFF”;

tab2.backgroundColor = “transparent”;

tab2Label.color = “#146F15”;

Ti.App.Properties.setString(‘unitType’, 0);

if (slider.max == 10.0) {

slider.max = 16.1;

slider.value = slider.value * 1.6093;

};

});

tab2.addEventListener(‘click’, function() {

tab2.backgroundColor = “#146F15”;

tab2Label.color = “#FFFFFF”;

tab1.backgroundColor = “transparent”;

tab1Label.color = “#146F15”;

});

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s