'UINavigationBar overlaps with status bar after presented VC with prefersStatusBarHidden as true

Presenting a VC(1) on Root VC(0) with prefersStatusBarHidden as true. After that dismissing the presented vc(1) and pushing another vc on root vc(2) with prefersStatusBarHidden as false. UINavigationBar going under status bar as below:

enter image description here

This issue is persisting When I go back to root view controller as well. All the view controllers in the navigation stack are facing the issue.

I got this while migrating from Xcode 12 to Xcode 13.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source