简体   繁体   中英

Ionic Status Bar Issue IOS

I am using the status bar plugin :

https://github.com/apache/cordova-plugin-statusbar

and in my config.xml I have the following set:

<preference name="StatusBarOverlaysWebView" value="true"/>
<preference name="StatusBarStyle" value="lightcontent" />

<feature name="StatusBar">
   <param name="ios-package" value="CDVStatusBar" onload="true" />
</feature>

and in my app.js, I have this:

if (window.StatusBar) {
    if (ionic.Platform.isAndroid()) {
        StatusBar.backgroundColorByHexString("#2DBE60");
    } else {
        StatusBar.styleLightContent();
    }
}

It works fine on Android but in IOS, if I set the StatusBarOverlaysWebView to true, the view is behind the status bar and that's not what I want. If I set the StatusBarOverlaysWebView to false, it works, but the issue is when the transitions to another, the status bar turns black for a few seconds and then goes white again.

How can I set it so that top status bar is white and stays that way even when navigating between pages on IOS .

Did you try the statusBarInstace.hide() method of the same plugin?

In one case, i had to write this below code inside the platform.ready function in the constructor of the page i am showing.

platform.ready().then(()=> statusbar.hide());

At time you may need to wrap the above code in a setTimeout function to cause a delayed execution.

Good luck

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