2

I currently use UIModalPresenationOverFullScreen to present the next controller and at this moment I want to change the UIStatusBarStyle. The previous controller has got the UIStatusBarStyleDefault but in the current I want to use UIStatusBarStyleLightContent.

Because of the UIModalPresenationOverFullScreen the previous controller is still alive in the background. Which causes the problem that the current will inherit that style.

In the plist file I've set View controller-based status bar appearance to YES and have been trying with some tips like:

[self setNeedsStatusBarAppearanceUpdate];
self.navigationController.navigationBar.barStyle =UIStatusBarStyleLightContent;
- (UIStatusBarStyle)preferredStatusBarStyle { 
      return UIStatusBarStyleLightContent; 
}

Nothings seems to work. Anyone who'r run into the same problem. I still want the previous controller to be alive but change the UIStatusBarstyle.

Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
Martin
  • 23
  • 2
  • use in viewdidLoad next controller "[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; [self setNeedsStatusBarAppearanceUpdate];" – the1pawan Mar 13 '15 at 11:29
  • Doesn't work. Same problem, still defaultstyle. @the1pawan – Martin Mar 13 '15 at 14:38

1 Answers1

7

You may use

self.modalPresentationCapturesStatusBarAppearance = YES;

in the modal controller.

From the documentation:

modalPresentationCapturesStatusBarAppearance Property

Specifies whether a view controller, presented non-fullscreen, takes over control of status bar appearance from the presenting view controller.

Community
  • 1
  • 1
StaS
  • 71
  • 1
  • 3