2

I know how to remove the status bar but this automatically snaps my navigation controller and its navigation bar to the top of the screen.

How can I remove the status bar but keep the 20 px space at the top of the screen, so I can put my own custom view or window in that space?

Max
  • 2,699
  • 2
  • 27
  • 50

1 Answers1

1

Create a custom UINavigationController and override the viewDidAppear

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
        CGRect f = self.view.frame;
        self.view.frame = CGRectMake(0,20,f.size.width,f.size.height-20);
        //the custom view for replacing the status bar.
        //you can add any custom subview you want 
        UIView *iv = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,20)];
        //assign a color with alpha less than 1.0 to make it translucent
        iv.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5];
        //remember to remove the iv when you don't need the navigation controller any more.
        [self.view.window insertSubview:iv aboveSubview:self.view];
    }
Danyun Liu
  • 3,072
  • 24
  • 22
  • Hey, Thank you! That works but: Is it possible to have the statusbar semi-transparent this way and show the content of the main view underneath the status bar this way? I tried it and I couldn't make it work yet. – Max Mar 28 '14 at 14:19
  • Do you want to remove the status bar or make the status bar translucent? The status bar is translucent by default for ios7. – Danyun Liu Mar 28 '14 at 14:36
  • I want to remove the standard status bar completely, so no battery and clock. Then put my own in, to show custom information for my app. But I want it to look exactly like the Apple bar, so translucent and the main view should show underneath it. – Max Mar 28 '14 at 14:54
  • Thanks for your effort but it doesn't work. The content of the main view is not visible underneath the status when leaving the main view. – Max Mar 28 '14 at 15:43
  • Well okay, thanks anyway. I'll mark it as correct and ask again for the exact thing I'm looking for – Max Mar 28 '14 at 18:53