Search code examples
iosswiftxcodestoryboarduistoryboard

Top Bar occupies invisible space, leaves empty space in viewcontroller xcode storyboard


I've recently updated my XCode to the latest version and I came across an unknown bug like, I'm unable to understand what could be the reason behind this bug.

Before updating the XCode all the layouts were working fine but after the update, this is what happened.

enter image description here

enter image description here

enter image description here

The Stimulated Metrics are same for all my view controllers throughout the project, but some of the layouts are pushed down by some unknown space and I tried adding

self.navigationController?.setNavigationBarHidden(true, animated: false)

But still it showed the same result.

When I changed the Top Bar attribute to None in Stimulated Metrics for the view controllers having this issue, it fixed the layout. But during run time showed the same bug in layout as shown above.

Could some one please help me with this? I don't seem to understand what is causing this behaviour.

Thank you


Solution

  • This looks like you are going to another view controller and this is happening.

    You need to make the style fullscreen which the below code will do for you

    let objSecondVc = self.storyboard?.instantiateViewController(withIdentifier: "ViewController") as? ViewController
    objSecondVc!.modalPresentationStyle = .fullScreen
    present(objSecondVc!, animated: true, completion: nil)