Can't set color of statusbar with cordova-plugin-statusbar

前端 未结 3 1757
有刺的猬
有刺的猬 2021-01-01 02:10

I\'m trying to change the color of the native status bar in an ionic app, but I can\'t get it to work. I\'ve installed cordova-plugin-statusbar, and it installs fine. The fo

相关标签:
3条回答
  • 2021-01-01 02:45

    Could you try removing the status bar plugin and reinstalling like so:

    ionic plugin rm org.apache.cordova.statusbar
    ionic plugin add https://github.com/apache/cordova-plugin-statusbar.git
    

    The same has been reported at the ionic issue tracker

    0 讨论(0)
  • 2021-01-01 02:52

    Gil's solution doesn't work for me (I've a Samsung Galaxy S7 Edge).

    onDeviceReady: function () {
        app.receivedEvent('deviceready');
        console.log(StatusBar);
        if (window.cordova && StatusBar) {
            StatusBar.backgroundColorByHexString('#BE1912');
        }
    },
    
    0 讨论(0)
  • 2021-01-01 02:53

    See me original solution at Can't get cordova-plugin-statusbar to set color on Android

    Add the plugin. Run shell command:

    $ cordova plugin add cordova-plugin-statusbar
    

    Edit your config.xml:

    <preference name="StatusBarOverlaysWebView" value="true" />
    <preference name="StatusBarBackgroundColor" value="#BE1912" />
    

    '#BE1912' is the default color (on app starts).

    Change in run time from your java script code:

    if (window.cordova && StatusBar)
    {
        StatusBar.backgroundColorByHexString('#BE1912');
    }
    
    0 讨论(0)
提交回复
热议问题