iOS 7 Status bar transparency

26,784

Solution 1

I'll answer to my own question, sorry about the waste of time.

My mistake was, the status bar was transparent. But for whatever reason, calling

[self.navigationController setNavigationBarHidden:YES animated:YES];

changed the top inset of my scrollview from 0.f to 20.f... So, I had a black background under my status bar, and therefore, a black status bar.

Thanks anyway !

Solution 2

Add this code to your .m file:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}
Share:
26,784
DCMaxxx
Author by

DCMaxxx

Objective C lover. Interested in almost everything about computer sciences. Student at Epitech, currently studying abroad at RMIT, Australia

Updated on August 05, 2022

Comments

  • DCMaxxx
    DCMaxxx almost 2 years

    I'm stuck on something that looks trivial, but I really don't understand what's happening.

    I'm compiling with iOS 7 SDK, and can't get the status bar to be transparent. It's fully black. In my .plist, Status bar style is Transparent black style (alpha of 0.5). I've tried all the other options, but I couldn't get it to work.

    I still need to support iOS 6, but I'd expect iOS 7 status bar to be transparent by default, right ?

    Any idea on what could cause this ?

    Thanks

  • DCMaxxx
    DCMaxxx over 10 years
    I've tried this, that's pretty much every SO answer about that. No matter what View controller-based status bar appearance is set to in this info.plist, this function isn't called (can't fire a breakpoint, nor an NSLog)
  • DCMaxxx
    DCMaxxx over 10 years
    For the record, the error came from automaticallyAdjustsScrollViewInsets set to YES.
  • stuckj
    stuckj about 10 years
    You just made my day. Had the same problem with initial display of a view inside a UIPageViewController. The UIPageViewController went under the status bar, but the initial page in the controller would be offset below the status bar. I was also using setNavigationBarHidden with the animation to display the page controller. Setting automaticallyAdjustsScrollViewInsets to NO in the page controller fixed it. You just ended a day of banging my head against the wall...thanks. :)