如何设置特定页面的状态栏的颜色只能用离子2

问题描述:

我使用创建的Android移动应用程序中使用的离子2.如何设置特定页面的状态栏的颜色只能用离子2

我正在使用status bar plugin。但我想改变状态栏背景颜色每个页面的状态栏颜色。

当我在app.component.ts中使用下面的代码。但它反映到所有页面。如何实现它?

import { StatusBar } from '@ionic-native/status-bar'; 

constructor(private statusBar:StatusBar){ 

    this.platform.ready().then(() => { 
    this.statusBar.backgroundColorByHexString('#ff6d79'); 
    this.splashScreen.hide(); 
    }); 
} 

在每个页面上,您应该单独设置它。

import { StatusBar } from '@ionic-native/status-bar'; 

export class HomePage { 

    constructor(private statusBar:StatusBar){ 

    } 

    ionViewDidLoad() { 
    this.statusBar.backgroundColorByHexString('#ff6d79'); 
    } 

} 
+0

但它增加了代码。另一种方式来实现它在一个共同的组件? – Sakthivel

+0

是的,您可以订阅根NavController事件并将其设置在那里。 – JoeriShoeby