[英]Wrong alignment of navigation bar button for second view controller in iOS 13
I am adding a button using the storyboard as below screenshot:我正在使用 storyboard 添加一个按钮,如下图所示:
While presenting from 1st controller to 2nd controller, navigation bar button alignment is not displaying properly.从第一个 controller 到第二个 controller 呈现时,导航栏按钮 alignment 无法正确显示。
I don't know whether it's iOS 13 problem or what.不知道是iOS 13问题还是什么。
To fix this issue, you need to call setNeedLayout manually in the viewWillAppear method as mentioned below:要解决此问题,您需要在 viewWillAppear 方法中手动调用 setNeedLayout,如下所述:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.