xcode 无法更改导航栏高度 ios 11

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48102678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:30:24  来源:igfitidea点击:

Cant change navigation bar height ios 11

swiftxcodeuinavigationbarios10ios11

提问by jMelvins

I cant change navigation bar frame in ios 11. Here is sample of my code for ios 10:

我无法在 ios 11 中更改导航栏框架。这是我的 ios 10 代码示例:

if let navigationBar = self.navigationController?.navigationBar {
    let frame = CGRect(x: navigationBar.frame.origin.x,
                       y: navigationBar.frame.origin.y,
                       width: navigationBar.frame.width,
                       height: navigationBar.frame.height + 100)
    navigationBar.frame = frame
}

ios 10 and ios 11 screenshots respectively

ios 10 和 ios 11 分别截图

ios 10 nav barios 11 nav bar

ios 10 导航栏ios 11 导航栏

回答by Upholder Of Truth

Changing the height of the UINavigationBar is no longer directly supported in iOS 11 (see here, here& here).

iOS 11 不再直接支持更改 UINavigationBar 的高度(请参阅此处此处此处)。

The best you can hope for is to do something like having a view behind the navigation bar and removing the borders (see herefor customisation examples).

您所能希望的最好的事情就是在导航栏后面有一个视图并删除边框(请参见此处的自定义示例)。