How to change the navigation bar height

后端 未结 3 948
小鲜肉
小鲜肉 2021-01-13 08:58

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

相关标签:
3条回答
  • 2021-01-13 09:39
    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];
    
    0 讨论(0)
  • 2021-01-13 09:41

    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:

    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

    0 讨论(0)
  • 2021-01-13 09:44

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

    0 讨论(0)
提交回复
热议问题