28

We are currently having an issue with navigation bar sizing when using modal presentation in iOS 13.

In most cases this works fine as can be seen in this screenshot:

However, in a few screens we get this weird effect, with the navigation bar having a lower height and a weird "see-through" gap between it and the view. As seen in this screenshot:

Both of the view controllers have the same values set for their properties, are modally presented and have the same constrains on their subviews (0 spacing from the superview/margins/top layout guide).

This issue doesn't happen in iOS 12, even when built with the iOS 13 SDK. Is this a known issue in iOS 13 (beta 8), or is there something we should adjust in the code/storyboard?

7
  • never saw that, can you provide sample project?
    – Lu_
    Sep 4, 2019 at 9:39
  • @LeonLucardie Hi ,maybe this should be solved after ios 13 stable version be released . Sep 5, 2019 at 2:42
  • @JuniorJiang-MSFT Yeah. I will check this issue again after iOS 13/XCode GM builds have been released. Since it also happens in XCode Swift/ObjC projects (as can be seen in the test project) we can at least rule out any Xamarin related issues. Sep 5, 2019 at 8:17
  • @JuniorJiang-MSFT Unfortunately it seems the issue still occurs in the stable (GM) version of iOS 13 and XCode 11 Sep 11, 2019 at 15:39
  • @LeonLucardie Sad hearing that .Does it also happens in XCode Swift/ObjC projects ? Sep 12, 2019 at 2:08

3 Answers 3

31
override func viewWillAppear(_ animated: Bool) {  
    super.viewWillAppear(animated)  
    if #available(iOS 13.0, *) {  
        navigationController?.navigationBar.setNeedsLayout()  
    }
}  

We found this work around here and it worked for us.

0
19

Like Rod's answer, but I found it only works if I put setNeetsLayout() in next main thread runLoop:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    // Workaround for iOS 13 modal gap below navigationbar
    if #available(iOS 13.0, *) {
        DispatchQueue.main.async {
            self.navigationController?.navigationBar.setNeedsLayout()
        }
    }
}
0
0

In case these answers don't work make sure to set the navigation bar type to "Standard".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.