【问题标题】:Ionic 5 set collapsable header color on iOSIonic 5 在 iOS 上设置可折叠标题颜色
【发布时间】:2020-07-15 05:52:56
【问题描述】:

我的应用 UI 很复杂,所以我举一个例子来说明我的问题。在 Ionic 5 上,我的代码直接取自官方 docs

<ion-header translucent="true">
  <ion-toolbar>   
    <ion-buttons collapse="true" slot="end">
      <ion-button>Click Me</ion-button>
    </ion-buttons> 
    <ion-title>Settings</ion-title>               
  </ion-toolbar>
</ion-header>

<ion-content fullscreen="true">
  <ion-header collapse="condense">              
    <ion-toolbar>      
      <ion-buttons collapse="true" slot="end">
        <ion-button>Click Me</ion-button>
      </ion-buttons>
      <ion-title size="large">Settings</ion-title>
    </ion-toolbar>
    <ion-toolbar>
      <ion-searchbar></ion-searchbar>
    </ion-toolbar>
  </ion-header>

  ...

</ion-content>

如果我以&lt;ion-toolbar color="primary"&gt; 之类的方式设置工具栏的颜色,我会得到这样的结果

如何设置彩色工具栏上方空间的颜色?

【问题讨论】:

    标签: css angular ionic-framework ionic5


    【解决方案1】:

    也有同样的问题,从global.scss控制我所有的工具栏css来设置背景颜色:

    ion-toolbar {
      background: var(--ion-color-primary) !important;
    }
    

    在哪里 --ion-color-primary 是我想要的颜色

    【讨论】:

    • 感谢您的回答。我想补充一点,如果您想为不同的页面设置不同的样式,这也适用于组件scss
    猜你喜欢
    • 2011-10-03
    • 1970-01-01
    • 2019-05-02
    • 2015-11-16
    • 2018-06-22
    • 1970-01-01
    • 2021-05-19
    • 2020-11-18
    相关资源
    最近更新 更多