Before clicking on the UIViewController add your custom button to the UITabBar
After pop UIViewController restore custom button for self.view
Subclass of UITabViewController
NSArray *array= self.viewControllers; for(UIViewController *controller in array){ if([controller isKindOfClass:[UINavigationController class]]){ UINavigationController *navigationController=(UINavigationController*)controller; navigationController.delegate=self; } }
Implement delegation method
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if (viewController.hidesBottomBarWhenPushed) { CGRect rect= [button convertRect:button.bounds toView:self.tabBar]; [button removeFromSuperview]; [self.tabBar addSubview:button]; button.frame=rect; } } -(void)navigationController:(nonnull UINavigationController *)navigationController didShowViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated{ if(!viewController.hidesBottomBarWhenPushed){ CGRect rect= [button convertRect:button.bounds toView:self.view]; [button removeFromSuperview]; [self.view addSubview:button]; button.frame=rect; } }
Jiang qi
source share