简体   繁体   中英

Status bar text color changing

So I have an app which mainly consists of web views. Everyhting is working fine, I have my status bar and navigation bars configured as I like.

The only issue is, when I go to a website that has a "Choose File" option, it opens the Saved Images to select a image (no issue here), then when I tap on the saved images table cell, the status bar text goes from white to black and I am unable to revert back.

I have tried calling UIStatusBarStyleLightContent in viewDidAppear , viewDidDisappear , etc which solves it reverting, but only on that single view it changes.

Any ideas on how to keep it UIStatusBarStyleLightContent all the time? I should note I have [UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; declared in the App Delegate, and UIViewControllerBasedStatusBarAppearance set to NO .

Thanks.

UPDATE with screenshots: 正确显示。无法正确显示。

UPDATE 7/14

I managed to get it somewhat working, but in turn it broke the default video player status bar text. Plus it just won't hide to begin with.

I used:

- (void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

-(void) viewDidDisappear:(BOOL)animated {
    [self.webView stopLoading];
    [self.navigationController setNavigationBarHidden:YES];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}

FINAL UPDATE??

Not pretty, but i managed to somewhat get the effect all together between the video player and image uploader.

-(void) viewDidDisappear:(BOOL)animated {
    [self.webView stopLoading];
    [self.navigationController setNavigationBarHidden:YES];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    [[UIApplication sharedApplication] setStatusBarHidden:YES
                                            withAnimation:UIStatusBarAnimationNone];
}

Set "View controller-based status bar appearance” to NO in your info.list file;

Add this code

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

to -application:didFinishLaunchingWithOptions: of the AppDelegate.m.

I hope your problem will be solved

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM