The first step, find Tabbarcontroller Viewwillappear method, register Tabbar upcoming, hidden notifications
-(void) viewwillappear: (BOOL) animated { [Super viewwillappear:animated]; Object : nil]; Object : nil]; Object : nil]; }
Second step, receive notification callback
- (void) Didreceivenotifications: (Nsnotification *) Sender {if(!_middleimage) {_middleimage= [UIImage imagenamed:@"Camera_button_take.png"]; } if(!_middlebutton) {[Self addcenterbuttonwithimage:[uiimage imagenamed:@"Camera_button_take.png"] Highlightimage:[uiimage imagenamed:@"Tabbar_camerabutton_ready_matte.png"]]; } if([Sender.name Isequaltostring:zsytabbarwillhidennotifykey]) {[Self _hidetabbarmiddlebutton]; } Else if([Sender.name Isequaltostring:zsytabbarwillshownotifykey]) {[Self _showtabbarmiddlebutton]; }}
Fourth step, Tabbarcontroller viewwilldisappear, remove notification
-(void) viewwilldisappear: (BOOL) animated { [Super viewwilldisappear:animated]; Object : nil]; Object : nil];}
Fifth step, show Tabbar the middle of the irregular button
-(void) _showtabbarmiddlebutton { @weakify (self); [UIView animatewithduration: 0.2f animations:^{ @strongify (self); = self.middleButton.frame; = [UIScreen mainscreen].bounds.size.height- self.middleImage.size.height; = frame; }];}
Sixth step, hide the tabbar middle of the irregular button
-(void) _hidetabbarmiddlebutton { @weakify (self); [UIView animatewithduration: 0.2f animations:^{ @strongify (self); = self.middleButton.frame; = [UIScreen mainscreen].bounds.size.height; = frame; }];}
Seventh step, in [tabbarcontroller.view addsubview: Custom button as Tabbaritem]
-(void) Addcenterbuttonwithimage: (uiimage*) buttonimage highlightimage: (uiimage*) highlightimage{UIButton* Button =[UIButton Buttonwithtype:uibuttontypecustom]; Button.autoresizingmask= Uiviewautoresizingflexiblerightmargin | Uiviewautoresizingflexibleleftmargin | Uiviewautoresizingflexiblebottommargin |Uiviewautoresizingflexibletopmargin; Button.frame= CGRectMake (0.0,0.0, ButtonImage.size.width, buttonImage.size.height); [Button Setbackgroundimage:buttonimage Forstate:uicontrolstatenormal]; [Button Setbackgroundimage:highlightimage forstate:uicontrolstatehighlighted]; CGFloat heightdifference= ButtonImage.size.height-Self.tabBar.frame.size.height; if(Heightdifference <0) Button.center=Self.tabBar.center; Else{Cgpoint Center=Self.tabBar.center; Center.y= center.y-heightdifference/2.0; Button.center=Center; } [button Addtarget:self action: @selector (Middlebuttondidclick) forcontrolevents:uicontroleventtouchupinside]; [Self.view Addsubview:button]; Self.middlebutton=button;}
customizing irregular Tabbaritem