2012-04-03 31 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