更改颜色导航栏标题 Ionic 2 [英] Change colour navbar header Ionic 2
问题描述
我有这个问题...我现在的颜色是白色的,我的代码是这样的:
<离子导航栏><离子标题>你好</ion-title></ion-navbar></ion-header>
使用此选项更改颜色很容易(主要、次要、危险、浅色、深色)
<离子导航栏危险><离子标题>你好</ion-title></ion-navbar></ion-header>
但我的问题是当我想使用自定义颜色时.有人知道我该如何解决吗?提前致谢.
最好的问候.
有两种方法可以做到这一点,基于是只想在单个页面中更改颜色,还是想在所有页面中更改颜色您应用中的页面:
1) 在单个页面/视图中更改它
就像您可以在此处
看到一样<块引用>要更改主题,只需调整您的 $colors
地图src/theme/variables.scss
文件:
$colors: (//...新颜色:#55acee)
然后在视图中使用
<ion-navbar color="newcolor"><离子标题>你好</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 {背景:线性渐变(135deg,$header-first-color 0%,$header-last-color 100%);}}
I have this problem... My colour is white right now, my code is like this:
<ion-header >
<ion-navbar>
<ion-title>
HELLO
</ion-title>
</ion-navbar>
</ion-header>
Change color with this opcion is easy (primary, secondary, danger, light, dark)
<ion-header >
<ion-navbar danger>
<ion-title>
HELLO
</ion-title>
</ion-navbar>
</ion-header>
but my problem is when I want to use custom colors. Somebody know how can I resolve it? Thanks inadvance.
Best regards.
There're two ways of doing this, based on if you want to change the color only in a single page, or if you want to change it in all the pages from your app:
1) Change it in a single page/view
Just like you can see here
To change the theme, just tweak the
$colors
map in yoursrc/theme/variables.scss
file:
$colors: (
// ...
newcolor: #55acee
)
And then use it in the view
<ion-header>
<ion-navbar color="newcolor">
<ion-title>
HELLO
</ion-title>
</ion-navbar>
</ion-header>
2) Change it in all the pages/views
In this case, you'd need to add the following in your variables.scss
file to override Ionic's defaults:
$toolbar-ios-background: #55acee;
$toolbar-md-background: #55acee;
$toolbar-wp-background: #55acee;
Edit
Hi, how can I add gradient in app/theme/app.variables.scss?
You could add the colors that you're going to use in the src/theme/variables.scss
:
$header-first-color: #AAAAAA;
$header-last-color: #000000;
And then set a rule to use it (in your app.scss
file if you want to apply it to every page, or in the page-name.scss
file if you want to apply it to a single page):
ion-header {
.toolbar-background {
background: linear-gradient(135deg, $header-first-color 0%, $header-last-color 100%);
}
}
这篇关于更改颜色导航栏标题 Ionic 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!