Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8697771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:36:03+00:00 2026-06-13T01:36:03+00:00

I’m running into a bit of a weird problem when hiding the status bar

  • 0

I’m running into a bit of a weird problem when hiding the status bar after the view had loaded. If I add the following method in the ViewDidLoad method, the status bar is completely removed from the view:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

However, if I call this method in an IBAction or another method, the status bar still slides away but leaves a black bar the same height as itself behind.

I’ve thought about shifting the entire view up by 20px but is this really a fix? I don’t want to just overlap a black bar incase the status bar height changes in future OS upgrades.

Status bar leaving black bar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:36:05+00:00Added an answer on June 13, 2026 at 1:36 am

    Hard-coding any number is always counter to future proofing. Your concerns are correct. There is a bit of a trick to properly handling the hiding of the statusBar. But all the needed information is available.

    For example the UIApplication singleton has a property named statusBarFrame which is precisely what it sounds like, a CGRect of the statusBar‘s frame. The cool thing is that once you have called setStatusBarHidden:withAnimation: that property will give you the new frame, even before the animation completes. So really you are simply left with some basic math to adjust the view‘s frame.

    In short your gut feeling is correct; always compute things live.

    I’ve had good success with a category method like this. (Even when toggling in-call status bar in simulator(Command – T)):

    @implementation UIApplication (nj_SmartStatusBar)
    // Always designate your custom methods by prefix.
    -(void)nj_setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation{
        UIWindow *window = [self.windows objectAtIndex:0];
        UIViewController *rootViewController = window.rootViewController;
        UIView *view = rootViewController.view;
    
        // slight optimization to avoid unnecassary calls.
        BOOL isHiddenNow = self.statusBarHidden;
        if (hidden == isHiddenNow) return;
    
        // Hide/Unhide the status bar
        [self setStatusBarHidden:hidden withAnimation:animation];
    
        // Get statusBar's frame
        CGRect statusBarFrame = self.statusBarFrame;
        // Establish a baseline frame.
        CGRect newViewFrame = window.bounds;
    
        // Check if statusBar's frame is worth dodging.
        if (!CGRectEqualToRect(statusBarFrame, CGRectZero)){
            UIInterfaceOrientation currentOrientation = rootViewController.interfaceOrientation;
            if (UIInterfaceOrientationIsPortrait(currentOrientation)){
                // If portrait we need to shrink height
                newViewFrame.size.height -= statusBarFrame.size.height;
                if (currentOrientation == UIInterfaceOrientationPortrait){
                    // If not upside-down move down the origin.
                    newViewFrame.origin.y += statusBarFrame.size.height;
                }
            } else { // Is landscape / Slightly trickier.
                // For portrait we shink width (for status bar on side of window)
                newViewFrame.size.width -= statusBarFrame.size.width;
                if (currentOrientation == UIInterfaceOrientationLandscapeLeft){
                    // If the status bar is on the left side of the window we move the origin over.
                    newViewFrame.origin.x += statusBarFrame.size.width;
                }
            }
        }
        // Animate... Play with duration later...
        [UIView animateWithDuration:0.35 animations:^{
            view.frame = newViewFrame;
        }];
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I've tracked down a weird MySQL problem to the two different ways I was
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.