2017-10-12 36 views
0

我使用創建的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(); 
    }); 
} 

回答

0

在每個頁面上,您應該單獨設置它。

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

export class HomePage { 

    constructor(private statusBar:StatusBar){ 

    } 

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

} 
+0

但它增加了代碼。另一種方式來實現它在一個共同的組件? – Sakthivel

+0

是的,您可以訂閱根NavController事件並將其設置在那裏。 – JoeriShoeby