要在React Navigation中设置标题样式,请在navigationOptions对象中使用标题对象:
static navigationOptions = {
header: {
titleStyle: {
/* this only styles the title/text (font, color etc.) */
},
style: {
/* this will style the header, but does NOT change the text */
},
tintColor: {
/* this will color your back and forward arrows or left and right icons */
}
}
}
要设置backgroundColor
的样式,只需在应用程序中设置backgroundColor
,否则将获得默认 colored颜色 .
UPDATE!! As of May 2017 beta9 the navigationOptions are now flat
你可以read about the breaking change here
您需要从header对象中删除对象键.另外,请注意,它们已被重命名.
static navigationOptions = {
title: 'some string title',
headerTitleStyle: {
/* */
},
headerStyle: {
/* */
},
headerTintColor: {
/* */
},
}