How to change the height of the navigation bar

I saw a decision to change the height of the navigation bar. But nothing worked for me. Now my application has one view controller connected to the navigation controller. I have not yet implemented any other code in my project. Before starting my project, I need to change the height of my navigation bar.

edited by:

.h:

- (CGSize)sizeThatFits:(CGSize)size ; 

.m:

 @implementation UINavigationBar (customNav) - (CGSize)sizeThatFits:(CGSize)size { CGSize newSize = CGSizeMake(370,40); return newSize; } @end 
+5
source share
3 answers
 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]; 
+2
source

You cannot change the height of the UINavigation, but you can add a custom view to the UINavigation panel

0
source

A very simple solution to this problem is that you can create a view from StoryBoard or from code.

And add a view to your viewController.

You need to disable the default navigation bar from your project. You can also do this using storyboards. Select the navigation bar and change the status bar to none:

enter image description here

And if you want to do this through code, then in didFinishLaunching enter this code:

 UIStoryboard *tStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; RootVC* RootVCObj = [tStoryBoard instantiateViewControllerWithIdentifier:@"RootVC"]; UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:RootVCObj]; navC.navigationBarHidden = YES; 

After that add as many buttons as you like

The main disadvantages of this is that you need to make your own presentation for all the screens that you currently have

0
source

Source: https://habr.com/ru/post/1239992/


All Articles