在Ionic 2中隐藏StatusBar

RHU*_*HUL 5 cordova-2.0.0 cordova-plugins ionic2 angular

我使用Ionic 2构建了一个应用程序.当我在浏览器中运行它时,UI看起来不错,但是一旦我在iOS模拟器中运行,一切看起来都很笨重.问题在于状态栏.我需要隐藏状态栏.我尝试使用离子原生的StatusBar,像这样 -

    import {StatusBar} from 'ionic-native';
constructor(platform: Platform) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.hide();
      //StatusBar.styleDefault();
    });
Run Code Online (Sandbox Code Playgroud)

但实际上它没有隐藏状态栏,而是它只是覆盖状态栏颜色与我的页面标题颜色.隐藏状态栏的任何解决方案.

S.Y*_*dav 1

我正在研究 ionic3,希望它也适用于 ionic 2。我也需要同样的东西,这是我的本地设置-

li packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0
Run Code Online (Sandbox Code Playgroud)

现在对以下文件进行更改:

配置文件

<preference name="Fullscreen" value="true" />
Run Code Online (Sandbox Code Playgroud)

组件.ts

StatusBar.overlaysWebView(true);
Run Code Online (Sandbox Code Playgroud)

这对我有用。

注意:- 更改仅反映在模拟器或 Android 手机中,而不反映在浏览器中。