Search code examples
iosobjective-cuistatusbar

Changing status bar style after viewDidLoad in iOS


So I know that in my ViewController.m I can override my

-(UIStatusBarStyle) preferredStatusBarStyle

method to change the return of the preferredStatusBarStyle. But here's the thing: I have a property

@property UIStatusBarStyle *customPreferredStatusBarStyle

and I'm changing the value of customPreferredStatusBarStyle in this bridge block:

[_bridge registerHandler:@"setStatusBarHandler_iOS" handler:^(id data, WVJBResponseCallback responseCallback) {
_customPreferredStatusBarStyle = UIStatusBarStyleDefault;
}]

which means if the website calls the bridge I'll change its value. But I found out that **-(UIStatusBarStyle) preferredStatusBarStyle** method only gets called once when the ViewController is initiated.

Is there any way for me to change my status bar style after the the bridge gets called?


Solution

  • Just call:

    Obj-C

    [self setNeedsStatusBarAppearanceUpdate];
    

    Swift

    setNeedsStatusBarAppearanceUpdate()