在哪里更改 iPhone 应用程序导航栏的高度?
在我的 applicationDidFinishLaunching 中,我设置了一个 UINavigationController:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
navController = [[UINavigationController alloc] init];
[[navController navigationBar] setFrame:CGRectMake(0.0,0.0,320.0,20.0)];
...
}
如您所见,我试图将导航控制器的高度设置为 20px。然而,这是行不通的。我想 setFrame 一定是正确的函数,但我没有在正确的位置调用它。我意识到 SO 上的其他问题与我的类似,但我认为如果它响应 setFrame,设置 navigationBar 高度应该是可能的......对吗?
另外,有人知道导航栏的默认高度吗?
谢谢!
In my applicationDidFinishLaunching I set up a UINavigationController:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
navController = [[UINavigationController alloc] init];
[[navController navigationBar] setFrame:CGRectMake(0.0,0.0,320.0,20.0)];
...
}
As you can see, I am trying to make the navigation controller's height 20px. However, this is not working. I would imagine setFrame must be the correct function but I am not calling it in the right place. I realize that other questions on SO are similar to mine, but I think setting the navigationBar height should be possible if it responds to setFrame...right?
Also, anyone know the default height of the navigationBar?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
导航栏的默认高度为 44px。
我不确定您是否应该尝试直接调整导航栏的大小,文档肯定不鼓励这样做:
根据您想要执行的操作,将新的 UIView 放置在导航栏上方/下方可能会更容易。
The default height of the navigation bar is 44px.
I am not sure you should be attempting to directly resize the navigation bar, the documentation certainly discourages it:
Depending on what you are trying to do it may be easier to place a new UIView over/below the navigation bar.
导航栏的默认高度为 44 像素。
如果您想更改它,请尝试向 UINavigationBar 添加一个类别并覆盖 setFrame: 方法。
Default height is 44 pixels for navigationbar.
If you want to change it, try adding a category to UINavigationBar and override setFrame: method.