5

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.

edited:

.h:

- (CGSize)sizeThatFits:(CGSize)size ;

.m:

@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size {
    CGSize newSize = CGSizeMake(370,40);
    return newSize;
}
@end
david
  • 636
  • 2
  • 12
  • 29
  • see this one : http://stackoverflow.com/questions/26380873/hide-status-bar-and-increase-the-height-of-uinavigationbar/26381417#26381417 – Kirit Modi Jan 06 '16 at 12:35
  • see link : http://stackoverflow.com/questions/2133257/iphone-how-set-uinavigationbar-height – darshan Jan 06 '16 at 12:44
  • but the width is showing for half size only.......for height is ok!..but how to set the width height that will equall for all 5,5s,6,6s,6+,6s screens – david Jan 06 '16 at 12:48
  • http://stackoverflow.com/questions/894985/change-uinavigationbar-height – Rahul Jan 06 '16 at 13:13
  • @RahulMishra i tried that height is working but my width is differing for all screen – david Jan 06 '16 at 13:15
  • Hows that is possible ? are you using autolayouts ? – Rahul Jan 06 '16 at 13:24
  • @user5737947 is their any problem using your own view instead of default navigation bar ? – Rahul Jan 06 '16 at 13:25

3 Answers3

2
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];
Jugal K Balara
  • 917
  • 5
  • 15
0

You can not change UINavigation height but you can add you custom view on UINavigation bar

Jugal K Balara
  • 917
  • 5
  • 15
  • can you give me some code explain ...bez i have many screen which are connected with navigation bar.....so how can i add custom view to set for all screen and also i am having some title and bar button item. – david Jan 06 '16 at 12:50
  • 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]; – Jugal K Balara Jan 06 '16 at 12:52
0

Very simple solution to this problem is you can create view from StoryBoard or from Code.

And add the view to your viewController.

You have to disable default navigation Bar from you project. You can do it by Storyboard also. Select your navigation bar and change the Status Bar to none:

enter image description here

And If you want to do via code then in your didFinishLaunching wirte this code:

UIStoryboard *tStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    RootVC* RootVCObj = [tStoryBoard instantiateViewControllerWithIdentifier:@"RootVC"];

    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:RootVCObj];
    navC.navigationBarHidden = YES;

After this add as many as Buttons to your view

Main cons of this is that you have to make custom view for all Screens you currently have

Rahul
  • 5,594
  • 7
  • 38
  • 92
  • Any solution please https://stackoverflow.com/questions/46251141/swipe-left-or-right-to-load-the-view-controller-with-the-collection-view-cell-hi – david Sep 16 '17 at 09:42