UINavigationController within ViewController, gap at top of view

后端 未结 11 997
不知归路
不知归路 2021-02-04 03:24

I\'m working on a universal app, and I\'m trying to share as much code as possible between the iPhone and iPad versions. I need to use a TabBarController as my root view contro

11条回答
  •  一生所求
    2021-02-04 03:38

    I was able to brute force as follows. In viewDidLoad or loadView:

    if (self.navigationController.navigationBar.frame.origin.y > 0.0) {
        self.navigationController.navigationBar.frame = CGRectOffset(self.navigationController.navigationBar.frame, 0.0, -20.0);
    }
    

    And in viewDidAppear:

    if (self.view.superview.frame.origin.y > 44.0) {
        UIView *container = self.view.superview;
        container.frame = CGRectMake(container.frame.origin.x, container.frame.origin.y - 20.0, container.frame.size.width, container.frame.size.height + 20.0);
    }
    

    It's ugly, but it seems to work.

提交回复
热议问题