如何更改导航栏高度 [英] How to change the navigation bar height
本文介绍了如何更改导航栏高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到了一个改变导航栏高度的解决方案。但没有什么对我有用。现在我的应用程序有一个与导航控制器连接的视图控制器。我还没有在我的项目中实现任何其他代码。在开始我的项目之前,我需要更改导航栏的高度。
I saw a solution to change the height of navigation bar. But nothing worked for me. Now my application has one view controller connected with a navigation controller. I have not yet implemented any other code in my project. Before starting my project I need to change my height of my navigation bar.
已编辑:
.h:
- (CGSize)sizeThatFits:(CGSize)size ;
.m:
@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size {
CGSize newSize = CGSizeMake(370,40);
return newSize;
}
@end
推荐答案
UIView *NavView = [[UIView alloc] initWithFrame:CGRectMake(0, 0 , [UIScreen mainScreen].bounds.size.width , 44)];
NavView.backgroundColor = [UIColor clearColor];
NavView.userInteractionEnabled = YES;
[self.navigationController.navigationBar addSubview:NavView];
UIButton *DateBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 10, 90, 30)];
DateBtn.backgroundColor = [UIColor clearColor];
[DateBtn setTitle:@"Jan 05" forState:UIControlStateNormal];
DateBtn.titleLabel.font = [UIFont fontWithName:BrushScriptStd size:18];
[DateBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[NavView addSubview:DateBtn];
这篇关于如何更改导航栏高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文