In your plist file, add the View controller-based status bar appearance Bool property and set it to YES.
Now in your view the controller will add the following methods:
// TO MAKE STATUS BAR WHITE override func preferredStatusBarStyle() -> UIStatusBarStyle { return .LightContent } // TO MAKE STATUS BAR BLACK override func preferredStatusBarStyle() -> UIStatusBarStyle { return .LightContent } // RETURN TRUE TO HIDE AND FALSE TO SHOW STATUS BAR override func prefersStatusBarHidden() -> Bool { return true }
For Objective-C
- (BOOL)prefersStatusBarHidden { return NO; } -(UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; }
To remove redundant code, you can make BaseViewController a subclass of UIViewController and add methods to this class. And override the method in the class that needs to be changed.
source share