本文介绍了如何防止iOS 13中的uinavigationbar和视图之间出现间隙?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前在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:

这两个视图控制器都为其属性设置了相同的值,以模态表示,并且在其子视图上具有相同的约束(与superview/margins/top布局指南的间距为0).

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).

即使使用iOS 13 SDK构建,此问题在iOS 12中也不会发生.这是iOS 13(测试版8)中的已知问题,还是我们应该在代码/故事板上进行一些调整?

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?

推荐答案

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.

这篇关于如何防止iOS 13中的uinavigationbar和视图之间出现间隙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 04:09