Resize for in-call status bar?

前端 未结 11 595
名媛妹妹
名媛妹妹 2020-11-29 03:06

How can I make my view resize in response to the in-call status bar from my nib?

I figured it would just be setting the resize properties, but they\'re not enabled f

11条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 03:40

    this works for me perfectly when my application is running in background and I press command + T. In my scenario , the root controller is my tab bar controller and I am readjusting my nav controller inside each tab.

    - (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame{
    [UIView animateWithDuration:0.35 animations:^{
        CGRect windowFrame = ((UINavigationController *)((UITabBarController *)self.window.rootViewController).viewControllers[0]).view.frame;
        if (newStatusBarFrame.size.height > 20) {
            windowFrame.origin.y = newStatusBarFrame.size.height - 20 ;// old status bar frame is 20
        }
        else{
            windowFrame.origin.y = 0.0;
        }
        ((UINavigationController *)((UITabBarController *)self.window.rootViewController).viewControllers[0]).view.frame = windowFrame;
    }];
    

    }

提交回复
热议问题