Auto Layout and “Hide bottom bar when pushed”

后端 未结 10 1965
Happy的楠姐
Happy的楠姐 2021-01-30 12:54

My app\'s (simplified) structure is this:

UITabBarController with one UINavigationController holding a UITableViewController as ro

10条回答
  •  猫巷女王i
    2021-01-30 13:35

    If you want the tab bar to be hidden, you can add this code to your controller,

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        self.tabBarController.tabBar.hidden = YES;
    }
    

    You will also have to put that code (but passing NO) into the controller where you want the tab bar to be visible. You should also deselect the "Hide bottom bar when pushed" box in IB.

    After Edit:

    You'll get a better animation if, in the first controller, you animate the alpha value of the non-hidden tab bar from 0 to 1 over a short time. This looks good if you go back with the back button. If you want to use the swipe back, you would have to do something more complicated involving the interactivePopGestureRecognizer.

    -(void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        self.tabBarController.tabBar.hidden = NO;
        self.tabBarController.tabBar.alpha = 0.0;
        [UIView animateWithDuration:.4 animations:^{
            self.tabBarController.tabBar.alpha = 1.0;
        }];
    }
    

提交回复
热议问题