Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the top bar text color to white in my Ionic App?

I changed the header to a darker color using this:

<ion-nav-bar class="bar-royal">

When I run it on ios, the status bar text (time, carrier, battery, etc) at the top is black and difficult to see on the dark background. How do I make this text white?

Black text on dark header color

like image 569
Ira Herman Avatar asked Feb 24 '15 20:02

Ira Herman


People also ask

How do I change text color in Ionic?

The text component is a simple component that can be used to style the text color of any element. The ion-text element should wrap the element in order to change the text color of that element.

How do I change primary colors in Ionic?

if you want to change primary color just change gold in --ion-color-gold: #ffd700; each line to primary in this way you can change it .

What is Ionic font?

With a large x-height and strong hairlines and serifs, the Ionic font family became widely used by the newspaper industry as a body type and provided a model for many twentieth century newspaper typefaces.


1 Answers

With the plugin statusbar and ngCordova is pretty simple:

var app = angular.module('ionicApp', ['ionic', 'ngCordova']);

app.run(function($cordovaStatusbar) {
  $cordovaStatusbar.overlaysWebView(true);

  $cordovaStatusBar.style(1); //Light
  $cordovaStatusBar.style(2); //Black, transulcent
  $cordovaStatusBar.style(3); //Black, opaque
});

Take a look to the full article here: http://learn.ionicframework.com/formulas/customizing-the-status-bar/

UPDATE - Without ngCordova:

Default Ionic project comes with the statusbar plugin installed. If you have this statement inside you run probably your project already have:

if(window.StatusBar) {
  StatusBar.styleDefault();
}

So the code become:

var app = angular.module('ionicApp', ['ionic']);

app.run(function() {
    if(window.StatusBar) {
      StatusBar.overlaysWebView(true);
      StatusBar.style(1); //Light
      StatusBar.style(2); //Black, transulcent
      StatusBar.style(3); //Black, opaque
    }
});

UPDATE II

With a new version 2.x of the cordova-plugin-statusbar the StatusBar.style() method was substituted with these new methods:

StatusBar.styleLightContent();
StatusBar.styleBlackTranslucent();
StatusBar.styleBlackOpaque();

Check the plugin's documentation

like image 99
manzapanza Avatar answered Nov 05 '22 12:11

manzapanza