How to Customize the tabbarcontroller

心已入冬 提交于 2019-12-12 09:27:14

问题


I need to add image to the tabbarcontroller. I included navigationcontroller as a tabbar item in tabbarcontroller. So how can i add image to the 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];
tabBarController.tabBarItem.title=@"TrackProgram";  
tabItem1.view.backgroundColor=[UIColor clearColor];


TrackClinic_iPhone *loc = [[TrackClinic_iPhone alloc] init];
UINavigationController *tabItem2 = [[[UINavigationController alloc] initWithRootViewController:loc] autorelease];
tabBarController.tabBarItem.title=@"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];

please help me to add image to tabbarcontroller.


回答1:


Custom TabBarController. various licenses.

https://github.com/aalittle/ALCustomTabBarController

https://github.com/i300/TweetBotTabBar

https://github.com/hollance/MHTabBarController

http://www.mobilebricks.com/ios/altabbarcontroller




回答2:


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

Add above line to each of your view controller. Also if you want total tabbar customized.Please go though following link. https://github.com/boctor/idev-recipes/downloads



来源:https://stackoverflow.com/questions/9990644/how-to-customize-the-tabbarcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!