2013-04-15 48 views
5

Tôi có một UINavigationController rằng khi sự kiện được kích hoạt, tôi cần một tuỳ chỉnh UIView để xuất hiện ngay bên dưới NavigationBar, nhưng không làm cản trở hiện tại ViewController. Tôi cũng sẽ cần phải làm cho UIView liên tục khi Bộ điều khiển được bật/đẩy.Thêm chế độ xem tùy chỉnh vào UINavigationController

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

Tôi hiện đang có của tôi CustomView (UIView) thiết lập khung như:

- (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)]; 
} 

Đây có phải là con đường để đi về điều này?

+0

thử này https://github.com/tursunovic/DMRNotificationView –

Trả lời

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; 
    } 

Sau đó

CustomView* _myCustomView = [[CustomView alloc] initWithNavigationController:navigationController]; 
[navigationcontroller.view addSubview:_myCustomView]; 
Các vấn đề liên quan