有两种方法可以做到这一点,具体取决于您是否只想在单个页面中更改颜色,或者如果您想在应用程序的所有页面中更改颜色:
1)在单个页面/视图中更改它
就像你在这里看到的一样
要更改主题,只需调整文件$colors
中的地图
src/theme/variables.scss
:
$colors: (
// ...
newcolor: #55acee
)
然后在视图中使用它
<ion-header>
<ion-navbar color="newcolor">
<ion-title>
HELLO
</ion-title>
</ion-navbar>
</ion-header>
2)在所有页面/视图中更改它
在这种情况下,您需要在variables.scss
文件中添加以下内容以覆盖 Ionic 的默认值:
$toolbar-ios-background: #55acee;
$toolbar-md-background: #55acee;
$toolbar-wp-background: #55acee;
编辑
嗨,如何在 app/theme/app.variables.scss 中添加渐变?
您可以在以下位置添加要使用的颜色src/theme/variables.scss
:
$header-first-color: #AAAAAA;
$header-last-color: #000000;
然后设置使用它的规则(app.scss
如果要将其应用于每个页面,则在page-name.scss
文件中,如果要将其应用于单个页面,则在文件中):
ion-header {
.toolbar-background {
background: linear-gradient(135deg, $header-first-color 0%, $header-last-color 100%);
}
}