我看到了更改导航栏高度的解决方案。但是对我没有任何作用。现在,我的应用程序具有一个与导航 Controller 连接的 View Controller 。我尚未在项目中实现任何其他代码。在开始我的项目之前,我需要更改导航栏的高度。

编辑:

。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];

10-08 05:56