【发布时间】:2018-10-03 10:04:16
【问题描述】:
版本:
"native-base": "^2.4.2",
"react": "16.3.1",
"react-native": "0.55.2",
"react-native-global-font": "^1.0.1",
"react-native-router-flux": "^4.0.0-beta.28",
"react-navigation": "^1.5.11"
当我添加 react-navigation 时,我无法更改状态栏颜色,我的状态栏变成蓝色。
这是我的 Navigationview.js 代码
render() {
return (
<Root style={styles.container}>
<StatusBar
backgroundColor="white"
barStyle="dark-content"
/>
<MainView />
</Root>
);
}
const drawerHeader = (props) => (
<Container style={styles.container}>
<Header style={styles.header}>
<Body style={styles.body}>
<Icon name="person" style={{ fontSize: 40, color: '#CCCCCC' }} />
</Body>
</Header>
<Content>
<SafeAreaView forceInset={{ top: 'always', horizontal: 'never' }}>
<DrawerItems {...props} />
<Button title="Logout" onPress={() => Actions.reset('login')} />
</SafeAreaView>
</Content>
</Container>
);
const MainView = DrawerNavigator({
DASHBOARD: {
screen: Dashboard,
},
LOGOUT: {
screen: LoginForm,
}
}, {
initialRouteName: 'DASHBOARD',
contentComponent: drawerHeader,
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToogleRoute: 'DrawerToogle'
});
i even set statusbar color in Dashboard screen, still not change.
Dashboard.js
<Container>
<Header androidStatusBarColor="#FFF" style={{backgroundColor:'#000'}}>
<StatusBar
backgroundColor="white"
barStyle="dark-content"
/>
<Body>
<Title style={{color:'#FFF'}}>My App</Title>
</Body>
</Header>
<Content>
//content of your app goes here
</Content>
</Container>
I m also using native-base, so i add this code in my App.js file
render() {
return (
<Root style={styles.container}>
<StatusBar
backgroundColor="white"
barStyle="dark-content"
/>
{this.spinerRender()}
</Root>
);
}
这适用于我的登录和登录屏幕,但不适用于我的导航视图屏幕。
登录和登录屏幕状态栏
导航屏幕状态栏
【问题讨论】:
-
你使用世博会吗?
-
@aLIEz no i m not using expo.
-
尝试将其包装在视图中并在根容器中添加一些高度,如提到的here
-
ParentWrapper 是从哪里派生出来的?
-
@NabeelK 是的,问题是原生组件。我更改了 contentComponent 视图。问题解决了。
标签: android react-native react-navigation native-base android-statusbar