【发布时间】:2018-07-11 11:03:00
【问题描述】:
我在我的项目中使用 react-native-navigation 库,但我的状态栏出现了一些问题。第一个是我无法在 iOS 上更改状态栏背景颜色,因此我为此创建了一个组件,如下所示:
const S_StatusBar = ({ backgroundColor, ...props }) => (
<View style={[styles.statusBar, { backgroundColor }]}>
<StatusBar translucent backgroundColor={backgroundColor} {...props} />
</View>
);
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 20 :
StatusBar.currentHeight;
const styles = StyleSheet.create({
statusBar: {
height: STATUSBAR_HEIGHT,
}
});
我在我的所有屏幕上导入这个组件,如下所示:
<View>
<S_StatusBar backgroundColor="#090b4b" barStyle="light-content" />
</View>
这是我使用 react-native-navigation 库推送屏幕的方法:
pushProductDetailScreen = () => {
this.props.navigator.push({
screen: 'cfl.ProductDetail'
});
};
屏幕已正确推送,但现在我的问题是我的状态栏位于导航栏下方,如下所示:
我不明白这个问题以及它发生的原因!
【问题讨论】:
-
这个问题你解决了吗?
标签: react-native react-native-android react-native-ios react-native-navigation