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.

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
UIApplicationsingleton has a property namedstatusBarFramewhich is precisely what it sounds like, aCGRectof thestatusBar‘s frame. The cool thing is that once you have calledsetStatusBarHidden: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 theview‘sframe.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)):