14

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.

How can I do that ?

Bhavin
  • 27,155
  • 11
  • 55
  • 94
DNB5brims
  • 29,344
  • 50
  • 131
  • 195

4 Answers4

64

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.

Byte
  • 2,920
  • 3
  • 33
  • 55
  • Thanks byte..It helped me..I was trying to add the view in navigtionBar of the navigationController..It did not allow user interaction..but when I did as you have mentioned, it works as expected.. – RK- Feb 13 '13 at 06:57
  • This was really helpful for me . is it possible to add an animation. like a silding down animation – Mr.G Apr 24 '13 at 07:02
  • @Mr.G Just offset the frame of `yourUIView` and use `UIView` method `+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations` – Byte Apr 26 '13 at 14:21
  • @Byte thanks for the reply . i managed to do it. once again thanks :> – Mr.G Apr 29 '13 at 07:30
  • This works on iOS 7 and iOS 8. On iOS 9 a keyboard dismiss event will remove the view from the hierarchy. ex. Showing an alert styled view and triggering the keyboard to dismiss in the background. – user2821144 Dec 10 '15 at 19:17
  • This point [self.navigationController.view addSubview:yourUIView] helped me a lot. – Ganesh G Jun 08 '17 at 10:13
2

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

Eiko
  • 25,601
  • 15
  • 56
  • 71
1

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];
}
Matt Becker
  • 2,338
  • 1
  • 28
  • 36
1

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];
Dharmesh Dhorajiya
  • 3,976
  • 9
  • 30
  • 39
dannywartnaby
  • 5,512
  • 2
  • 21
  • 11
  • I have a view that is a UIView, call "mainUIView", and a UIView called "subUIView", and I want the subUIView fill in the screen, except the status bar. – DNB5brims Aug 18 '10 at 10:53
  • OK, two choices - Use UIViewControllers and present/display as appropriate, or add subUIView as a subview of mainUIView or your application's UIWindow directly (as suggested by Eiko below). Both will work, but without understanding more of your use case, I couldn't say which is better/more appropriate. – dannywartnaby Aug 18 '10 at 11:13