[英]iOS 13 new pageSheet/formSheet navigationBar Height
As we can see from image below, the new presentation style of iOS 13 built with XCode 11 made navigation bar have a different height (56 height) compared to the one presented 'fullscreen' (44 height).从下图可以看出,iOS 13 采用 XCode 11 构建的新呈现风格使得导航栏的高度(56 高度)与呈现的“全屏”(44 高度)不同。
The problem here is my app is using a custom written navigation bar and the height of the custom navigation bar is calculated with UINavigationController.navigationBar.frame.height
which give us 44 height as default.这里的问题是我的应用程序正在使用自定义的书面导航栏,自定义导航栏的高度是使用
UINavigationController.navigationBar.frame.height
计算的,默认为 44 高度。 We are trying to adopt to the new presentation style, but I could not think of a work-around.我们正在尝试采用新的演示风格,但我想不出解决方法。 I think I'm also not covered situation such as large title navigation bar and compact navigation bar.
我想我也没有涵盖大标题导航栏和紧凑导航栏等情况。 Any help would be greatly appreciated.
任何帮助将不胜感激。
Credits to: https://medium.com/@hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e 归功于:https://medium.com/@hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e
2) Image with navigationBar Height of 56 in presentationStyle.pageSheet
2)presentationStyle.pageSheet 中 navigationBar 高度为 56 的图像
3) Image with navigationBar Height of 44 in presentationStyle.fullScreen
3)presentationStyle.fullScreen 中 navigationBar 高度为 44 的图像
This is seems to be a bug in iOS, I've used this workaround , but I call it in viewDidLoad
instead of viewWillAppear
because the latter applied the fix only after the view controller animation finished.这似乎是 iOS 中的一个错误,我已经使用了这个解决方法,但我在
viewDidLoad
而不是viewWillAppear
中调用它,因为后者仅在视图 controller Z6F1C25ED15235062F1BBF9DEE 完成后才应用修复。
override func viewDidLoad(_ animated: Bool) {
// ...
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.