2012-04-03 26 views
0

我需要添加图像到tabbarcontroller。我将navigationcontroller作为tabbarcontroller中的一个tabbar项目。那么我如何添加图像到tabbarcontroller。如何自定义tabbarcontroller

tabBarController = [[UITabBarController alloc] init]; 
tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlackOpaque; 
tabBarController.moreNavigationController.topViewController.view.backgroundColor=[UIColor clearColor]; 
tabBarController.delegate=self; 


Dashboard_iPhone *dash = [[Dashboard_iPhone alloc] init]; 
UINavigationController *tabItem0 = [[[UINavigationController alloc] initWithRootViewController:dash] autorelease]; 
tabItem0.view.backgroundColor=[UIColor clearColor]; 

    TrackProgram_iPhone *rep = [[TrackProgram_iPhone alloc] init]; 
UINavigationController *tabItem1 = [[[UINavigationController alloc] initWithRootViewController:rep] autorelease]; 
[email protected]"TrackProgram"; 
tabItem1.view.backgroundColor=[UIColor clearColor]; 


TrackClinic_iPhone *loc = [[TrackClinic_iPhone alloc] init]; 
UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController:loc] autorelease]; 
[email protected]"TrackClinic "; 
tabItem2.view.backgroundColor=[UIColor clearColor]; 



tabBarController.viewControllers=[NSArray arrayWithObjects:tabItem0,tabItem1,tabItem2,nil]; 


[self.view insertSubview:tabBarController.view belowSubview:dash.view ];  

[self presentModalViewController:tabBarController animated:NO]; 

请帮我添加图像到tabbarcontroller。

+0

你的意思了的TabBar项的图标?或背景,或甚至别的东西?请更具体一些。 – 2012-04-03 09:40:27

+0

标题和描述很混乱。你问如何添加图像在'tabbar'或如何定制它? – HelmiB 2012-04-03 09:55:01

回答

8
self.tabBarItem.image = [UIImage imageNamed:@"CamListIconNew.png"]; 

将以上行添加到您的每个视图控制器。 此外,如果你想要总tabbar customized.Please走虽然下面的链接。 https://github.com/boctor/idev-recipes/downloads