Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent gap between uinavigationbar and view in iOS 13?

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?

like image 300
Leon Lucardie Avatar asked Sep 04 '19 08:09

Leon Lucardie


People also ask

What is Navigation Controller in iOS?

The navigation controller manages the navigation bar at the top of the interface and an optional toolbar at the bottom of the interface. The navigation bar is always present and is managed by the navigation controller itself, which updates the navigation bar using the content provided by its child view controllers.

What is the height of navigation bar iPhone?

On iPhone tab bars remain 49 points tall in portrait and 32 points tall in landscape. iPhone X added extra height for the Home Bar to toolbars and tab bars and their sizes are unchanged from iOS 11: 83 points tall in portrait and 53 points tall in landscape.

How do I remove a navigation bar line in Swift?

One is the background image, and the other is the shadow image. First, we'll hide the shadow image, by setting it to empty image and see how it looks. Now, we'll also hide the background image just like shadow image, and it will look like the navigation bar has disappeared.

How do I use the navigation bar in Xcode?

Start with Navigation Controller Create a single view application in Xcode. Add two view controller into your storyboard. Create two different swift files for those view controllers and set identifiers for them. Take a button in each view controller, set constrain for them and customize as you want.

What happened to the navigation bar in ios13?

In iOS13 the default appearance of the large title style navigation bar has changed from translucent to transparent. Nothing changes much in a plain style table view, the navigation bar will show the color of a table view, in this case, white. For grouped style, there is also some offsetting change.

What is a navigation bar in uinavigationcontroller?

A navigation bar is most commonly used within a navigation controller. The UINavigationController object creates, displays, and manages its associated navigation bar, and uses attributes of the view controllers you add to control the content displayed in the navigation bar.

What is a navigation item in uinavigationitem?

Instead, you use a navigation item (an instance of the UINavigationItem class) to specify what buttons or custom views you want displayed. A navigation item has properties for specifying views on the left, right, and center of the navigation bar and for specifying a custom prompt string.

When to use scroll edge appearance in iOS 13?

The last one is Scroll edge appearance, based on WWDC session, Modernizing Your UI for iOS 13, this one will be used when navigation associated with a scroll view, but in my test, this one will be used for large title navigation bar even it does not have scroll view.


2 Answers

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.

like image 66
Rod Avatar answered Sep 25 '22 17:09

Rod


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()         }     } } 
like image 23
Jakehao Avatar answered Sep 21 '22 17:09

Jakehao