使用Router Flux更改NavBar元素的颜色

时间:2018-05-25 13:49:35

标签: react-native react-native-router-flux

我正在尝试更改后退按钮(左V形)的颜色和右侧文字的颜色。但它不起作用。有人能指出我有什么不对吗?谢谢!

import React from 'react';
import { Router, Scene, Stack } from 'react-native-router-flux';
import { Actions } from 'react-native-router-flux';
import { Image} from 'react-native';

//Scenes
import Welcome from './src/scenes/Welcome';
import Home from './src/scenes/Home';
import SignUp from './src/scenes/SignUp';
import TextView from './src/scenes/TextView'

export default props => (
  <Router navigationBarStyle={{ backgroundColor: '#68d6f9'}} 
        titleStyle={{ color: '#FFF'}}
        backButtonBarStyle={{color : "#FFF"}}
        barButtonTextStyle={{color: 'red'}}>
    <Stack key='root'>
        <Scene key='welcome' component={Welcome} title='Welcome' hideNavBar={ true } initial />
        <Scene key='home' component={Home} title='Home' hideNavBar={ false } left={()=>null}  />
        <Scene key='textView' component={TextView} title='TextView' hideNavBar={ false } backTitle=' ' />
        <Scene key='signUp' component={SignUp} title='Registration' hideNavBar={ false }
               left={<Image style={{height:40, width: 50, marginLeft: 20, marginTop:3}} source={require('./src/imgs/nelson.png')}></Image>}
               rightTitle={'X'}
               onRight={ () => Actions.welcome()}/>
    </Stack>
</Router> 
);

1 个答案:

答案 0 :(得分:0)

您可以在titleStyle中使用navigationBarStyleleftButtonIconStyleScene来自定义您的风格。

这样的事情:

<Scene
  initial
  key="key"
  renderLeftButton={<IconComponent />}
  component={MyComponent}
  title="My Title"
  titleStyle={titleStyle}
  navigationBarStyle={navigationBarStyle}
  leftButtonIconStyle={leftButtonIconStyle}
/>

希望有所帮助