Code Monkey home page Code Monkey logo

custom_ios_tabbar's Introduction

Custom Tab Bar

TODO:

  • Add support for orientation change

Easily extend tabbar in Appcelerator Titanium mobile for iPhone app to allow any image to be used!

This class is everything short of just being able to drop it in and be done.

  1. include the customTabBar with:

    Ti.include("/tabbar_module/customTabBar.js");

  2. Change your existing:

    Ti.UI.createTabGroup(); Including any properties you might be passing to it. And change it to:

    createCustomTabGroup();

  3. Add any of your new custom properties to your tabs. The available properties are:

    tabHeight - an int value for the height of the tab (default is 49) Note: tabWidth does not exist as image scales based on height when set modal - a bool value if you want this tab to behave normally, or open in a modal window

  4. Two new methods are added now as well, and they are as follows:

    hideTabBar() - Hides the tabBar showTabBar() - Shows the tabBar

Here is an example of the CustomTabBar in use:

// include the new class
Ti.include("/tabbar_module/customTabBar.js");

// create tab group
var tabGroup = createCustomTabGroup();


//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    custom:true,
    window:win1
});

var label1 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 1',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win1.add(label1);

//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'red'
});
	close = Ti.UI.createButton({
		title:'Close'
	})
	close.addEventListener('click', function() {
		win2.close();
	});
	win2.setRightNavButton(close);
	
var tab2 = Titanium.UI.createTab({  
    icon:'new.png',
    tabHeight:60,
    tabWidth:190,
    custom:true,
    modal: true,
    window:win2
});

var label2 = Titanium.UI.createLabel({
	color:'#fff',
	text:'I am Window 2',
	font:{fontSize:20,fontFamily:'Helvetica Neue', fontWeight: 'bold'},
	textAlign:'center',
	width:'auto'
});


var win3 = Titanium.UI.createWindow({  
    title:'Tab 3',
    backgroundColor:'#fff'
});
var tab3 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 3',
    window:win3
});

var label3 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 3',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win3.add(label3);

//
//  add tabs
//
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  
tabGroup.addTab(tab3);  


// open tab group
tabGroup.open();

tabGroup.hideTabBar();

setTimeout(function(){
	tabGroup.showTabBar();
}, 700);

custom_ios_tabbar's People

Contributors

mattapperson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.