此行为归因于iOS 13中的错误。可以通过在导航栏上调用setNeedsLayout进行修复。
快速示例:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
}
Objective-C示例:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Fix navigation item placement on iOS 13: https://forums.developer.apple.com/thread/121861
if (@available(iOS 13.0, *)) {
[self.navigationController.navigationBar setNeedsLayout];
}
}
贷方:在Apple Developer Form上从this thread借用的解决方案。