React Native状态栏

3

我正在尝试为我的Android模拟器样式化statusBar,但它的深度和绿色有点过于浓重。如何设置高度?

 render() {
    const { navigationState, dispatch } = this.props;
    return (
      <View>
        <StatusBar translucent backgroundColor="#000" />
        <View style={styles.appBar} />
        <View style={styles.content} />

        <NavigationStack
          navigation={addNavigationHelpers({
            dispatch,
            state: navigationState,
            addListener
          })}
        />
      </View>
    );
  }
}


const STATUSBAR_HEIGHT = Platform.OS === "ios" ? 20 : StatusBar.currentHeight;
const APPBAR_HEIGHT = Platform.OS === "ios" ? 44 : 56;

const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  statusBar: {
    height: STATUSBAR_HEIGHT
  },
  appBar: {
    backgroundColor: "#79B45D",
    height: APPBAR_HEIGHT
  },
  content: {
    flex: 1,
    backgroundColor: "#33373B"
  }
});

enter image description here

1个回答

0

render() {
    const { navigationState, dispatch } = this.props;
    return (
      <View style={styles.container}>
        <StatusBar
     backgroundColor="blue"
     barStyle="light-content"
 />

        <NavigationStack
          navigation={addNavigationHelpers({
            dispatch,
            state: navigationState,
            addListener
          })}
        />
      </View>
    );
  }
}


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接