Controller 呈现以下代码:
let vc = UIViewController()
vc.view.backgroundColor = Colors.green
let nvc = UINavigationController(rootViewController: vc)
self.present(nvc, animated: true, completion: nil)
显示
但是导航栏高度很大。应该是这样的
如何像第二张图片那样设置导航栏高度?
最佳答案
来自the discussion in apple developer forum ,这似乎是iOS 13中的一个错误。
他们提供的解决方法如下:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
}
我已经在我的项目中对其进行了测试,它解决了问题。希望它也能解决您的问题。
关于ios - iOS 13 中 Controller 呈现模态时的 UINavigationBar 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58107039/