xcode ios7 导航栏高度使用故事板调整大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21494995/
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 04:36:44  来源:igfitidea点击:

ios7 navigation bar height resize using storyboard

xcodeios7storyboardnavigationbar

提问by o242

I just want to use navigation bar in UIViewController.

我只想在UIViewController.

in iOS7, if we use navigation controller, the navigation bar height is 64px.

在iOS7中,如果我们使用导航控制器,导航栏高度为64px。

but when I use navigation bar in UIViewController, I can't change navigation bar height.

但是当我在 中使用导航栏时UIViewController,我无法更改导航栏高度。

the height is fixed 44px.

高度固定为 44px。

How can I change navigation bar's height using Interface builder, not programming?

如何使用界面构建器而不是编程更改导航栏的高度?

enter image description here

在此处输入图片说明

Apple doesn't support this feature in xcode storyboard?

Apple 在 xcode 故事板中不支持此功能?

回答by Rob T

If you add a fixed height constraint to the UINavigationBar using autolayout, changing the height constraint constant will update the nav bar's height. You adjust this in the storyboard using the size inspector.

如果您使用自动布局向 UINavigationBar 添加固定高度约束,则更改高度约束常量将更新导航栏的高度。您可以使用大小检查器在故事板中调整它。

Before adding fixed height constraint:

在添加固定高度约束之前:

nav_bar_before

nav_bar_before

After adding fixed height constraint:

添加固定高度约束后:

nav_bar_after

nav_bar_after

回答by ramsserio

You can try this Code:

你可以试试这个代码:

@interface UINavigationBar (myNave)
- (CGSize)changeHeight:(CGSize)size;
@end


@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size {
    CGSize newSize = CGSizeMake(320,70);
    return newSize;
}
@end

For more info visit : http://tutorialmode.com/ios/customising-an-ios-navigation-bar/

欲了解更多信息,请访问:http: //tutorialmode.com/ios/customising-an-ios-navigation-bar/