How to remove iOS status bar with Phonegap Build?

前端 未结 9 2026
走了就别回头了
走了就别回头了 2021-02-02 10:11

Is it possible to get rid of the status bar in iOS7 when using Phonegap Build 3.1? I can remove the status bar when building locally in Xcode, but as soon as I try Phonegap Buil

相关标签:
9条回答
  • 2021-02-02 10:40

    Simply install the status bar plugin (I'm using Cordova 5.x):

    cordova plugin add cordova-plugin-statusbar@1.0.1
    

    The in your code just reference its global variable and use .hide():

    StatusBar.hide()
    
    0 讨论(0)
  • 2021-02-02 10:43

    Add this function into MainViewController.m file:

    //fix not hide status on ios7
    - (BOOL)prefersStatusBarHidden
    {
        return YES;
    }
    
    0 讨论(0)
  • 2021-02-02 10:49

    As of Phonegap 3 you can now customize plist files via config.xml.

    Code:

    <gap:config-file platform="ios" parent="UIViewControllerBasedStatusBarAppearance" overwrite="true">
        <false/>
    </gap:config-file>
    
    0 讨论(0)
  • 2021-02-02 10:50

    I've answered this for removing the Status bar altogether in your previous question

    The essential part:

    I got this to work beautifully in Cordova 3.6 + iOS 7.1. And considering that iOS 7 and 8 each have 50% of market share this solution should be enough.

    Plugin I'm using: org.apache.cordova.statusbar

    Instead of using StatusBar.hide() I used:

    var hideSb = function(){
    //        StatusBar.hide;
            cordova.exec(null, null, 'StatusBar', 'hide', ['Ehi', 'You']);
        };
    
    0 讨论(0)
  • 2021-02-02 10:55

    I'm using the following in config.xml which completely removes the status bar, tested on iOS 7.0.3 & 7.0.4, Phonegap version 3.0.0 if that helps.

        <preference name="fullscreen" value="true" />
    
    0 讨论(0)
  • 2021-02-02 10:56

    Usually, you would edit the info.plist and add this key:

     <key>UIViewControllerBasedStatusBarAppearance</key><false/>
    

    But as you can't do this on build, you'll have to add a plugin:

    https://github.com/phonegap-build/StatusBarPlugin/blob/master/README.md

    And then:

    StatusBar.hide();

    0 讨论(0)
提交回复
热议问题