[英]My navigation bar doesn't go to the top of the screen in Xcode 13.0
I am using a navigation controller and my navigation bar will not extend to the top of the screen.我正在使用导航 controller,我的导航栏不会延伸到屏幕顶部。 I never had an issue with this until I updated Xcode to version 13.0.
在我将 Xcode 更新到版本 13.0 之前,我从来没有遇到过这个问题。 I am using storyboard and can't figure out why this issue is happening.
我正在使用 storyboard 并且无法弄清楚为什么会发生此问题。 (See photo)
(见照片)
If you are looking for how to make it with storyboards, simply turn on "Scroll Edge" in the attributes inspector, while you tap on the Navigation bar... image here如果您正在寻找如何使用故事板制作它,只需在属性检查器中打开“滚动边缘”,同时点击导航栏...图像在这里
If you are not using storyboards, try setting a delegate object for the navigation bar.如果您不使用故事板,请尝试为导航栏设置委托 object。
navigationBar.delegate = self
Conform UIBarPositioningDelegate in your delegate object and attach bar to the top在您的委托 object 中符合 UIBarPositioningDelegate 并将栏附加到顶部
ViewController: UIViewController, UIBarPositioningDelegate {
func position(for bar: UIBarPositioning) -> UIBarPosition {
return .topAttached
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.