How to make a UIView that can cover the navigation bar?

后端 未结 4 2006
再見小時候
再見小時候 2021-02-19 07:47

I want to show the UIView in full screen, but show the status bar, other things, like the navigation bar need to cover by the UIView.

相关标签:
4条回答
  • 2021-02-19 08:09

    I believe what he was asking was how to make a UIView cover the entire screen (sort of like custom pop up). This is precisely how I ended up here. So I will offer my solution. Call this function anywhere.

    [self.navigationController.view addSubview:yourUIView];
    

    Here the view you introduced cover over the whole screen unlike

    [self.view addSubview:yourUIView]; 
    

    Whereby, the navigation bar is uncovered.

    0 讨论(0)
  • 2021-02-19 08:18

    Add the view to your main UIWindow instance directly as a subview.

    0 讨论(0)
  • 2021-02-19 08:26

    I know the OP was looking for a way to cover the navigation bar totally, but instead of covering it, you could just temporarily hide it. Once hidden, you can add you view as a subView and change its frame or constraints so it takes up the whole screen.

    - (void)showViewOverNavBar:(UIView *)view {
    
        [self.navigationController setNavigationBarHidden:YES];
        [self.view addSubview:view];
    }
    
    0 讨论(0)
  • 2021-02-19 08:28

    Struggling a little to fully understand the question, but I think you're asking how you can display a UIView above another view (so that the view with the navigation controls is completely hidden by the second view)?

    UIViewController has:

    - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
    

    It would be wise to have your second view managed by a UIViewController, too. For the sake of example let's say your view with the navigation bar is managed by UINavigationViewController, and the view you want to display is managed by otherViewController...

    [navigationViewController presentModalViewController:otherViewController animated:YES];
    
    0 讨论(0)
提交回复
热议问题