i got the answer ....
h file code ...
@interface CustomTabBarController : UITabBarController
{
}
@end
@interface AroundParisAppDelegate : NSObject <UIApplicationDelegate,UITabBarControllerDelegate> {
UIImageView *imgTab ,*imghome ,*imgQuiz,*imgtTW, *imgGuest;
IBOutlet CustomTabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic,retain) IBOutlet CustomTabBarController *tabBarController;
-(void)tabBarControllerView;
@end
in m file :---
@synthesize tabBarController;
-(void)tabBarControllerView
{
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate = self;
Home *firstTabController =[[Home alloc]initWithNibName:@"Home" bundle:nil];
//-----second Tab -----//
quiz *secondTabController = [[quiz alloc]initWithNibName:@"quiz" bundle:nil];
//------3rd tab--//
tw *thirdControllerMap = [[tw alloc] initWithNibName:@"tw" bundle:nil];
//-----4th tab bar--------//
guest *fourthTabController = [[guest alloc] initWithNibName:@"guest" bundle:nil];
tabBarController.viewControllers = [NSArray arrayWithObjects:firstTabController, secondTabController,thirdControllerMap,fourthTabController, nil];
UINavigationController *objnavifirst=[[UINavigationController alloc] initWithRootViewController:firstTabController];
UINavigationController *objnavisecond=[[UINavigationController alloc] initWithRootViewController:secondTabController];
UINavigationController *objnavithird=[[UINavigationController alloc] initWithRootViewController:thirdControllerMap];
UINavigationController *objnavifourth=[[UINavigationController alloc] initWithRootViewController:fourthTabController];
NSMutableArray *MainNavArray =[[NSMutableArray alloc] init];
objnavifirst.navigationBarHidden=YES;
objnavisecond.navigationBarHidden=YES;
objnavithird.navigationBarHidden=YES;
objnavifourth.navigationBarHidden=YES;
[MainNavArray addObject:objnavifirst];
[MainNavArray addObject:objnavisecond];
[MainNavArray addObject:objnavithird];
[MainNavArray addObject:objnavifourth];
tabBarController.viewControllers =MainNavArray;
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
imgTab = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,320.0,50)];
imgTab.image=[UIImage imageNamed:@"Bottom-bar.png"];
tabBarController.tabBar.tag=10;
[tabBarController.tabBar addSubview:imgTab];
imghome=[[UIImageView alloc]initWithFrame:CGRectMake(2.0,00.0,76.0,49.0)];
imghome.image=[UIImage imageNamed:@"home-hover.png"];
[imgTab addSubview:imghome];
imgQuiz=[[UIImageView alloc]initWithFrame:CGRectMake(82.0,00.0,76.0,49.0)];
imgQuiz.image=[UIImage imageNamed:@"quiz.png"];
[imgTab addSubview:imgQuiz];
imgtTW=[[UIImageView alloc]initWithFrame:CGRectMake(164.0,00.0,76.0,49.0)];
imgtTW.image=[UIImage imageNamed:@"twitter.png"];
[imgTab addSubview:imgtTW];
imgGuest=[[UIImageView alloc]initWithFrame:CGRectMake(244.0,00.0,76.0,49.0)];
imgGuest.image=[UIImage imageNamed:@"guest.png"];
[imgTab addSubview:imgGuest];
tabBarController.view.hidden = NO;
tabBarController.selectedIndex = 1;
}
- (void)tabBarController:(UITabBarController *)tabBarControllers didSelectViewController:(UIViewController *)viewController
{
NSLog(@"%i",tabBarControllers.selectedIndex);
if (tabBarControllers.selectedIndex == 0)
{
imghome.image=[UIImage imageNamed:@"home-hover.png"];
imgQuiz.image=[UIImage imageNamed:@"quiz.png"];
imgtTW.image=[UIImage imageNamed:@"twitter.png"];
imgGuest.image=[UIImage imageNamed:@"guest.png"];
}
else if (tabBarControllers.selectedIndex == 1)
{
imghome.image=[UIImage imageNamed:@"home.png"];
imgQuiz.image=[UIImage imageNamed:@"quiz-hover.png"];
imgtTW.image=[UIImage imageNamed:@"twitter.png"];
imgGuest.image=[UIImage imageNamed:@"guest.png"];
}
else if (tabBarControllers.selectedIndex == 2)
{
imghome.image=[UIImage imageNamed:@"home.png"];
imgQuiz.image=[UIImage imageNamed:@"quiz.png"];
imgtTW.image=[UIImage imageNamed:@"twitter-hover.png"];
imgGuest.image=[UIImage imageNamed:@"guest.png"];
}
else if (tabBarControllers.selectedIndex == 3)
{
imghome.image=[UIImage imageNamed:@"home.png"];
imgQuiz.image=[UIImage imageNamed:@"quiz.png"];
imgtTW.image=[UIImage imageNamed:@"twitter.png"];
imgGuest.image=[UIImage imageNamed:@"guest-hover.png"];
}
}
this is full example for add tab bar
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…