React native 如何更改react navigation的导航选项中的标题样式?

React native 如何更改react navigation的导航选项中的标题样式?,react-native,react-navigation,React Native,React Navigation,例如字体颜色和字体大小可能是fontFamily static navigationOptions = { headerStyle: { backgroundColor: '#27A9E1', shadowColor: 'white', elevation: 0, }, title: 'PROFILE', (for example I tried something like titleStyle and headerTitleStyle: but didn't work???)

例如字体颜色和字体大小可能是fontFamily

static navigationOptions = {
headerStyle: {
  backgroundColor: '#27A9E1',
  shadowColor: 'white',
  elevation: 0,
},
title: 'PROFILE',
(for example I tried something like titleStyle and headerTitleStyle: but didn't work???)

})

headerTitleStyle选项应该可以工作。这其实不难在网上找到

用法:

static navigationOptions = {
  headerTitleStyle = { your styles here}
}

headerTitleStyle
选项应该可以工作。这其实不难在网上找到

用法:

static navigationOptions = {
  headerTitleStyle = { your styles here}
}

使用自定义组件渲染标头

// ProfileScreen.js
static navigationOptions = {
    header: props => (
      <Header
        {...props}
        title="PROFILE"
      />
    )
  };
//ProfileScreen.js
静态导航选项={
标题:道具=>(
)
};
这是您的自定义组件标题header.js

 //Header.js
    ...
    render() {
      const { title } = this.props
      return (
        <View>
          <Text style={styles.yourstyle}>{title}</Text>
        <View>
      )
    }
//Header.js
...
render(){
const{title}=this.props
返回(
{title}
)
}

使用自定义组件呈现标题

// ProfileScreen.js
static navigationOptions = {
    header: props => (
      <Header
        {...props}
        title="PROFILE"
      />
    )
  };
//ProfileScreen.js
静态导航选项={
标题:道具=>(
)
};
这是您的自定义组件标题header.js

 //Header.js
    ...
    render() {
      const { title } = this.props
      return (
        <View>
          <Text style={styles.yourstyle}>{title}</Text>
        <View>
      )
    }
//Header.js
...
render(){
const{title}=this.props
返回(
{title}
)
}

似乎每个导航器只能在NavigationOptions中设置一次headerTitleStyle。在代码中搜索较早出现的带有headerTitleStyle属性的导航选项。

似乎每个导航器只能在导航选项中设置一次headerTitleStyle。在代码中搜索较早出现的带有headerTitleStyle属性的导航。

我应该提到,我也尝试过,但似乎不起作用。。我试着喜欢这个headerTitleStyle:{textAlign:'center',alignSelf:'center',color:'white',fontSize:25,},它的哪一部分不起作用?文本颜色和字体大小应该可以,但是对齐一点用都没有。整个过程我甚至试着只保留颜色和字体大小,但它不起作用。。headerStyle适用于标题的背景色,但不适用于headerStyle您可能需要进行一些调试才能解决此问题,或者共享您正在使用的代码。我应该提到,我也尝试过,但似乎不起作用。。我试着喜欢这个headerTitleStyle:{textAlign:'center',alignSelf:'center',color:'white',fontSize:25,},它的哪一部分不起作用?文本颜色和字体大小应该可以,但是对齐一点用都没有。整个过程我甚至试着只保留颜色和字体大小,但它不起作用。。headerStyle适用于标题的背景色,但不适用于headerStyle您可能需要进行一些调试才能解决此问题,或者共享您正在使用的代码。如果选中
package.json
,您正在运行的
react导航
的哪个版本?如果选中
package.json
,您正在运行哪个版本的
react导航