- (void) viewdidload {[Super viewdidload]; //Do any additional setup after loading the view.Self.Delegate=Self ; /************************ hides the black lines on the Tabbar ***************************/CGRect rect= CGRectMake (0,0, Self.view.frame.size.width, self.view.frame.size.height); Uigraphicsbeginimagecontext (rect.size); Cgcontextref Context=Uigraphicsgetcurrentcontext (); Cgcontextsetfillcolorwithcolor (context, [[Uicolor Clearcolor] cgcolor]); Cgcontextfillrect (context, rect); UIImage*img =Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); [Self.tabbar setbackgroundimage:img]; [Self.tabbar setshadowimage:img]; /************************ hides the black lines on the Tabbar ***************************/Uitabbaritem*ITEM1 = [[Uitabbaritem alloc]initwithtitle:@"Home Page"Image:[[uiimage imagenamed:@"Tabbar_home"] Imagewithrenderingmode:uiimagerenderingmodealwaysoriginal] Tag:0]; Item1.selectedimage= [[UIImage imagenamed:@"tabbar_home_selected"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; Uitabbaritem*ITEM2 = [[Uitabbaritem alloc]initwithtitle:@""Image:[[uiimage imagenamed:@"Tabbar_order"] Imagewithrenderingmode:uiimagerenderingmodealwaysoriginal] Tag:0]; Uitabbaritem*ITEM3 = [[Uitabbaritem alloc]initwithtitle:@"my own"Image:[[uiimage imagenamed:@"Tabbar_person"] Imagewithrenderingmode:uiimagerenderingmodealwaysoriginal] Tag:0]; Item3.selectedimage= [[UIImage imagenamed:@"tabbar_person_selected"] imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; Nsarray*controllers = @[@"Homepage",@"Order",@" Person"]; for(inti =0; I <3; i++) {Class cls= Nsclassfromstring ([NSString stringWithFormat:@"% @ViewController", Controllers[i]]); Uiviewcontroller*controller = (Uiviewcontroller *) [[CLS Alloc] init]; Uinavigationcontroller*NC =[[Uinavigationcontroller alloc] initwithrootviewcontroller:controller]; Nc.tabbaritem=@[item1,item2,item3][i]; [Self ADDCHILDVIEWCONTROLLER:NC]; } Uiimageview*tabbarview = [[Uiimageview alloc] Initwithframe:cgrectmake (0, Self.tabBar.frame.size.height- A, Screen_width, A)]; Tabbarview.image= [UIImage imagenamed:@"Tabbar"]; [Self.tabbar Addsubview:tabbarview]; }-(BOOL) Tabbarcontroller: (Uitabbarcontroller *) Tabbarcontroller Shouldselectviewcontroller: (UIViewController *) Viewcontroller {if(Viewcontroller = = self.viewcontrollers[1]) { //Click the middle Tabbaritem, do not switch, let the current page jumpOrderviewcontroller *order =[[Orderviewcontroller alloc] init]; Order.hidesbottombarwhenpushed=YES; [(Uinavigationcontroller*) Tabbarcontroller.selectedviewcontroller Pushviewcontroller:order Animated:yes]; returnNO; } returnYES;}
To customize the Tabbar, click the middle button without toggling the page, but let the current child view controller jump to the new page. (similar to Sina Weibo release)