简体   繁体   中英

Ionic: Custom tab-bar background color on comment page?

Ionic 1.2

I'm trying to change the background color of the tab bar on a specific screen in my app where I have a text input sitting on top of the tab bar, similar to how Twitter's tab bar looks (see image below).

In other words, I want to change the background color of my tab bar from, say, black to white on a specific screen and otherwise keep the tab bar the default black color. The idea would be similar to adding a class to a specific screen to change the style of the tab bar.

Any thoughts? Any help much appreciated!

带有注释框的Twitter应用程序标签栏的屏幕截图

You can do this using ng-style .

在此处输入图片说明

1.) tabs.html

Add ng-style="{'background-color': Color}" inside <ion-tabs> .

<ion-tabs class="tabs-icon-top tabs-color-active-light" ng-style="{'background-color': Color}">

  //

</ion-tabs>

2.) controllers.js

Add $rootScope as dependency and following $ionicView to each controller (use same color in controllers where you have a text input sitting on top of the tab bar). For each tab choose different color.

$scope.$on('$ionicView.beforeEnter', function() {
  $rootScope.Color = 'red';
  });

3.) style.css

.tabs {
   background-color: inherit;
}

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM