2016-01-06 97 views
5

我看到了一個更改導航欄高度的解決方案。但沒有爲我工作。現在我的應用程序有一個視圖控制器連接到導航控制器。我還沒有在我的項目中實現任何其他代碼。在開始我的項目之前,我需要改變我的導航欄的高度。如何更改導航欄高度

編輯:

.H:

- (CGSize)sizeThatFits:(CGSize)size ; 

.M:

@implementation UINavigationBar (customNav) 
- (CGSize)sizeThatFits:(CGSize)size { 
    CGSize newSize = CGSizeMake(370,40); 
    return newSize; 
} 
@end 
+0

看到這一個:http://stackoverflow.com/questions/26380873/hide-status-bar-and-increase-the-height-of-uinavigationbar/26381417#26381417 –

+0

看到鏈接:http:// stackoverflow .com/questions/2133257/iphone-how-set-uinavigationbar-height – darshan

+0

但寬度只顯示一半大小.......對於高度是好的!..但如何設置寬度高度將等於爲所有5,5,6,6,6 +,6s屏幕 – david

回答

0

你不能改變UINavigation高度,但你可以添加自定義您查看UINavigation欄上

+0

你可以給我一些代碼解釋...因爲我有很多屏幕,這是與導航欄連接.....所以我怎麼可以添加自定義視圖設置爲所有屏幕,我也有一些標題和酒吧按鈕項目。 – david

+0

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

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]; 
+0

同時加入您的解決方案應我的導航控制器連接或不符合我的ViewController – david

+0

是的,你需要使用導航控制器 –

+0

連接我TREID但這麼想的工作 – david

0

很簡單解決這個問題的方法是從StoryBoard或代碼創建view

並將視圖添加到您的viewController。

您必須禁用項目的默認導航欄。你也可以通過Storyboard來完成。選擇您的導航欄和更改狀態欄,無:

enter image description here

,如果你想通過代碼來執行,然後在你的didFinishLaunching WIRTE此代碼:

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

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

在此之後添加多達按鈕到您的視圖

這主要的缺點是,你必須爲您目前所有的屏幕製作自定義視圖

+0

任何解決方案,請https://stackoverflow.com/questions/46251141/swipe-left-or-right-to-load-the-view-控制器與 - 所述收集 - 視圖 - 細胞喜 – david