向UINavigationController添加自定义视图

时间:2013-04-15 15:51:21

标签: ios uinavigationcontroller

我有UINavigationController,当事件触发时,我需要自定义UIView显示在NavigationBar下方,但不会阻碍当前ViewController

UIView

我目前正在设置我的 ----------------- | Status Bar | ----------------- | Nav Bar | ----------------- | Custom View | ----------------- | | | View Controller | | | ----------------- 框架,如:

CustomView (UIView)

这是解决这个问题的方法吗?

1 个答案:

答案 0 :(得分: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];
相关问题