1

I have a UIViewController with a childViewController.

The childViewController either takes up the entire screen or parts of the screens, overlaying on top of the parentViewController.

When it takes up the entire screen I would like to change the UIStatusBarStyle.

In my plist, I have added View controller-based status bar appearance and set it to NO.

In the childViewController I have the following:

-(UIStatusBarStyle)preferredStatusBarStyle {
    if (self.isFullScreen) {
        return UIStatusBarStyleDefault;
    } else {
        return UIStatusBarStyleLightContent;
    }
}

-(UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationFade;
}

When making the transition from half and fullscreen I call:

[self setNeedsStatusBarAppearanceUpdate];

But my UIStatusBar does not change appearance from light to dark.

A regular call to:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];

works fine, however but I would like to take advantage of the fact that I can match the animation duration for the change inside an animation block.

Thank you.

runmad
  • 14,846
  • 9
  • 99
  • 140
  • You should set View controller-based status bar appearance to YES for changing for using -(UIStatusBarAnimation)preferredStatusBarUpdateAnimation method. – Boran Oct 03 '13 at 19:25
  • @BoranA Ah! That helped... Also needed to set the `childViewControllerForStatusBarStyle`. Add answer so I can accept? – runmad Oct 03 '13 at 19:45

1 Answers1

0

You should set the UIViewControllerBasedStatusBarAppearance to YES in the plist for using -(UIStatusBarStyle)preferredStatusBarStyle method.

Boran
  • 949
  • 10
  • 17
  • 1
    Thanks. Just adding to the comment that I also had to set `(UIViewController*)childViewControllerForStatusBarStyle` for the `parentViewController` – runmad Oct 04 '13 at 13:41