适配iPhone X Push过程中TabBar位置上移

在UINavigationController的基类重写pushViewController代理方法,在Push的时候修正一下TabBar的frame

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {
            viewController.hidesBottomBarWhenPushed = YES;
        }
    [super pushViewController:viewController animated:animated];
    // 修改tabBra的frame
    CGRect frame = self.tabBarController.tabBar.frame;
    frame.origin.y = [UIScreen mainScreen].bounds.size.height - frame.size.height;
    self.tabBarController.tabBar.frame = frame;
}

你可能感兴趣的:(适配iPhone X Push过程中TabBar位置上移)