In fact, iOS Tabbar is very customizable, we do not need to build the wheel repeatedly, the following are some of the Tabbar collection of the regular use of settings. We hope to help you.
Set Tabbar selected color
IOS7 settings such as the following:
[self. Tabbarcontroller. TabBarsetselectedimagetintcolor: [uicolor greencolor]];
For example, the following settings are in iOS8:
Self.tabbar.tintcolor=[uicolor Greencolor];
Remove Tabbar Border
At the beginning of the program at Appdelegate:
[[Uitabbar appearance] setshadowimage:[[uiimage Alloc]init]];
[[Uitabbar appearance] setbackgroundimage:[[uiimage Alloc]init]];
Sets the Tabbar item original icon with the original selected icon. Instead of the system's own active fill color
Get TabBar in Get want to the item uitabbar *tabbar = _tabbarcontroller.tabbar; Uitabbaritem *item0 = [Tabbar.items objectatindex:0]; Uitabbaritem *item1 = [Tabbar.items objectatindex:1]; Uitabbaritem *item2 = [Tabbar.items objectatindex:2]; Uitabbaritem *item3 = [Tabbar.items objectatindex:3]; Set the corresponding picture to item item0.selectedimage = [[UIImage imagenamed:@ "Recognize-1"] Imagewithrenderingmode: Uiimagerenderingmodealwaysoriginal];; Item0.image = [[UIImage imagenamed:@ "recognize"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; Item1.selectedimage = [[UIImage imagenamed:@ "life-1"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];; Item1.image = [[UIImage imagenamed:@ "Life"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; Item2.selectedimage = [[UIImage imagenamed:@ "edit-1"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];; Item2.image = [[UIImage imagenamed:@ "edit] Imagewithrenderingmode:uiimagerenderingmodEalwaysoriginal]; Item3.selectedimage = [[UIImage imagenamed:@ "Setting-1"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal ];; Item3.image = [[UIImage imagenamed:@ "setting"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];
Set Tabbar background picture
UIView *backview = [[UIView alloc] Initwithframe:cgrectmake (0, 0, Main_screen_width,)]; Backview.backgroundcolor = [Uicolor redcolor]; [Self.tabbar Insertsubview:backview atindex:0]; Self.tabBar.opaque = YES;
Set the background picture when Tabbar item is selected
1, 5.0 or more version number
Self.tabBar.selectionIndicatorImage = [UIImage imagenamed:@ "System_tabbar_item_selected.png"];
2, 5.0 the following version number
The first implementation is for example the following methods :
-(void) Setnohighlisttabbar: (Uitabbarcontroller *) tabbarcontroller{nsarray * Tabbarsubviews = [ Tabbarcontroller.tabbar Subviews]; int Index4selview; if (Tabbarcontroller.selectedindex+1 > 4) {//selected The last tab. Index4selview = [Tabbarsubviews count]-1; } else if ([Tabbarcontroller.viewcontrollers count] > 5) {//have "more" tab. and Havn ' t selected the last tab: "Mor E "tab. Index4selview = [Tabbarsubviews Count]-5 + tabbarcontroller.selectedindex; } else {//have No "more" tab. Index4selview = [Tabbarsubviews count]-[tabbarcontroller.viewcontrollers count] + tabbarcontroller.selectedindex; } if ([Tabbarsubviews count] < index4selview+1) {assert (false); Return } UIView * SelView = [tabbarsubviews Objectatindex:index4selview]; Nsarray * selviewsubviews = [SelView subviews]; for (UIView * v in selviewsubviews) {if (v && [NSStRingfromclass ([v class]) isequaltostring:@ "Uitabbarselectionindicatorview") {//the V is the highlight view. [Self.selecteditembgimageview Removefromsuperview]; [SelView InsertSubview:self.selectedItemBgImageView belowsubview:v]; [v Removefromsuperview]; Break } }}
the essence of the method is to recycle the tabbar of the Subviews, find the Tabbar in the view, is a uitabbarselectionindicat orview view, Then replace it with the uiimageview you created, the Self.selecteditembgimageview in the example above.
then you need to set Uitabbarcontroller's delegate to self, and run the above method in Tabbarcontroller:didselectviewcontroller's proxy method: [Self Setnohighlisttabbar:self];
and setselectindex: [Self setnohighlisttabbar:self] in the method;
Some settings for iOS Tabbar