如何更改Stack Navigator Options Right Header的颜色

时间:2018-04-09 17:18:14

标签: react-native

我想更改堆栈导航器选项的rightHeader颜色。当我应用样式时,它给出了错误,说undefined不是一个对象。这是我的代码。我怎样才能解决这个问题?

我想将rightHeader颜色更改为蓝色。我在这里使用了可触摸的不透明度。

 static navigationOptions = {
    headerTitle: "Share To Feed",
    headerTitleStyle: {
      paddingLeft: "20%",
      paddingRight: "20%"
    },
    headerStyle: {
      paddingRight: 10,
      paddingLeft: 10
    },
    headerLeft: (
      <Icon
        name={"close"}
        size={30}
        onPress={() => {
          //this.props.navigation.navigate("comments");
        }}
      />
    ),
    headerRight: (
      <TouchableOpacity>
        <View style={styles.headerRight}>
          <Text>Post</Text>
        </View>
      </TouchableOpacity>
    )
  };
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  sharePostWrapper: {
    marginTop: 0,
    marginRight: 5,
    marginBottom: 5,
    marginLeft: 5,
    padding: 5,
    borderWidth: 1,
    borderColor: "gray"
  },
  image: {
    flex: 1,
    width: width - 20,
    height: 200
  },
  headerRight: {
    color: "blue"
  }
});

1 个答案:

答案 0 :(得分:2)

由于您在backgroundColor上应用了style,因此它应该是color而不是unstack()

color特定于Text类型的节点元素