1、在组件中配置导航条
//HomePage.js
export default class HomePage extends Component {
static navigationOptions = {
title: '网易云音乐',
};
...
}
2、在路由中配置导航条
routers/index.js
const AppNavigator = createStackNavigator(
{
Home: {
screen: HomePage,
navigationOptions:{
headerTitle:"网易", //导航名
headerStyle:{
backgroundColor:"#c20c0c" //导航背景颜色
},
headerTitleStyle:{
color:"#fff" // 字体颜色 也可以进行一些其他的设置
}
}
},
},
...
);
export default createAppContainer(AppNavigator);
3、默认全局导航条配置
const AppNavigator = createStackNavigator(
...
{
initialRouteName:"Home",
defaultNavigationOptions:{
headerStyle:{
backgroundColor:"#c20c0c"
},
headerTitleStyle:{
color:"#fff"
},
headerTintColor: '#fff' // 返回按钮的颜色
}
}
);
export default createAppContainer(AppNavigator);