An API is provided to control the display and hiding of the status bar

- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation;

- (UIViewController *)childViewControllerForStatusBarHidden;

- (BOOL)prefersStatusBarHidden;

- (void)setNeedsStatusBarAppearanceUpdate;
Copy the code

This set of rules was normal and life was good before the use of UINavigationBar. But when it comes to UINavigationBar, it’s crazy. You know what you’ve been through, no need to say more.

This library was born to solve various problems caused by hiding the status bar when there is a UINavigationBar.

Usage

Use hbd_statusBarHidden replace prefersStatusBarHidden hbd_setNeedsStatusBarHiddenUpdate replace to use setNeedsStatusBarAppearanceUpdate

Write the following code in the controller that needs to hide the status bar

#import <HBDStatusBar/UIViewController+StatusBar.h>

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.hbd_statusBarHidden = YES;
}Copy the code

or

- (BOOL)hbd_statusBarHidden {
    return YES;
}Copy the code

This is a declarative API, and other pages that don’t need to hide the status bar don’t need to do anything.

If you need a dynamic hide or show the status bar, hbd_setNeedsStatusBarHiddenUpdate after setting hbd_statusBarHidden call.

This library can play nice with UINavigationBar

You can still specify by preferredStatusBarUpdateAnimation show or hide the status bar at the time of the animation, Still can pass childViewControllerForStatusBarHidden to specify which controller to decide whether to hide status bar

If you encounter problems with UINavigationBar, please visit HBDNavigationBar.

Installation

HBDStatusBar is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'HBDStatusBar'Copy the code

Author

[email protected]

License

HBDStatusBar is available under the MIT license. See the LICENSE file for more info.