romaonthego / REFrostedViewController

iOS 7/8 style blurred view controller that appears on top of your view controller.
MIT License
2.97k stars 494 forks source link

Change UIStatusBar appearance on menu hide/show #56

Open runmad opened 10 years ago

runmad commented 10 years ago

Right now, I don't see any functionality for animation and changing the UIStatusBar style on menu hide/show. If I am using a black style for the frosted drawer I would prefer a white status bar, however the status bar has to be black for all other view controllers in the app.

kalys commented 10 years ago

IMO controlling status bar style is not responsibility of the library. It allows to use delegate methods for triggering appropriate events.

I archived this feature using the next steps:

Set View controller-based status bar appearance to NO in your .plist file. Then implement the following delegate methods of REFrostedViewControllerDelegate.

- (void) frostedViewController:(REFrostedViewController *)frostedViewController willShowMenuViewController:(UIViewController *)menuViewController {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
}

- (void) frostedViewController:(REFrostedViewController *)frostedViewController willHideMenuViewController:(UIViewController *)menuViewController {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}
runmad commented 10 years ago

Sure, but this approach isn't really appropriate for iOS 7 with the new methods for setting the animation behaviour and style for the status bar.

SpencerLynn commented 8 years ago

I added a PR with this functionality.

Just a note: if either view is a navigation controller, this won't just work. I don't feel this should be up to the library to make work. The library will let the contentViewController and menuViewController that you provide handle it.

To fix this I added this to my project, which basically takes the last view controller on the navigation stack and uses it to drive status bar style:

@implementation UINavigationController (StatusBarStyle)

-(UIViewController *)childViewControllerForStatusBarStyle {
    return self.viewControllers.lastObject;
}

-(UIViewController *)childViewControllerForStatusBarHidden {
    return self.viewControllers.lastObject;
}

@end