2013-04-15 117 views
5

我有一個UINavigationController,當事件被觸發時,我需要一個定製UIView出現只是NavigationBar下方,但不妨礙當前ViewController。我還需要在彈出/推送控制器時使UIView保持不變。添加自定義視圖的UINavigationController

----------------- 
| Status Bar | 
----------------- 
|  Nav Bar  | 
----------------- 
| Custom View | 
----------------- 
|     | 
| View Controller | 
|     | 
----------------- 

我目前有我CustomView (UIView)設置類似於框架:

- (id)initWithNavigationController:(UINavigationController *)navController { 
    self.navController = navController; 
    return [self init]; 
} 

- (id)init 
{ 
    CGRect viewFrame = self.navController.view.frame; 

    return [self initWithFrame:CGRectMake(viewFrame.origin.x, 
             self.navController.navigationBar.frame.origin.y + self.navController.navigationBar.frame.size.height, 
             viewFrame.size.width, 
             40.0)]; 
} 

這是去了解這個問題的方法?

+0

試試這個https://github.com/tursunovic/DMRNotificationView –

回答

0
- (id)initWithNavigationController:(UINavigationController *)navController { 
    CGRect viewFrame = navController.view.frame; 

    if (self = [super initWithFrame:CGRectMake(viewFrame.origin.x, 
             navController.navigationBar.frame.origin.y + navController.navigationBar.frame.size.height, 
             viewFrame.size.width, 
             40.0)]){ 
     self.navController = navController; 
     } 
    return self; 
    } 

然後

CustomView* _myCustomView = [[CustomView alloc] initWithNavigationController:navigationController]; 
[navigationcontroller.view addSubview:_myCustomView]; 
相關問題