UIViewController In-Call Status Bar Issue

前端 未结 8 921
误落风尘
误落风尘 2020-12-01 12:24

Issue:

Modally presented view controller does not move back up after in-call status bar disappears, leaving 20px empty/transparent space at the top.<

8条回答
  •  自闭症患者
    2020-12-01 13:19

    I faced this problem too but after I put this method, problem is gone.

    iOS has its default method willChangeStatusBarFrame for handling status bar. Please put this method and check it .

    func application(_ application: UIApplication, willChangeStatusBarFrame newStatusBarFrame: CGRect) {
        UIView.animate(withDuration: 0.35, animations: {() -> Void in
            let windowFrame: CGRect? = ((window?.rootViewController? as? UITabBarController)?.viewControllers[0] as? UINavigationController)?.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
            }
            ((window?.rootViewController? as? UITabBarController)?.viewControllers[0] as? UINavigationController)?.view?.frame = windowFrame
        })
    }
    

    Hope this thing will help you.
    Thank you

提交回复
热议问题