Expo(React Native)中的StatusBar背景色不起作用

时间:2019-11-13 09:13:52

标签: reactjs expo

StatusBar backgroundColor 道具在Expo Snack中也不起作用。仅工作道具隐藏 barStyle 。 Expo Snack的代码示例:

import * as React from 'react';
import { Text, View, StyleSheet, StatusBar } from 'react-native';
import Constants from 'expo-constants';

// You can import from local files
import AssetExample from './components/AssetExample';

// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <StatusBar backgroundColor="white" barStyle="dark-content" hidden={false} translucent={false}/>
        <Text style={styles.paragraph}>
          Change code in the editor and watch it change on your phone! Save to get a shareable url.
        </Text>
        <Card>
          <AssetExample />
        </Card>
      </View>
    );
  }
}

我还尝试在app.json中添加样式:

{
  "expo": {
    ...
    "androidStatusBar": {
      "backgroundColor": "#ffffff"
    }
  }
}

"androidStatusBarColor": "#ffffff", "androidStatusBar": { "barStyle": "dark-content", "backgroundColor": "#ffffff" }

我怎么了? 谢谢!

1 个答案:

答案 0 :(得分:0)

这是世博会的问题,一段时间以来,社区一直在寻求解决方案。但似乎在下一版本的Expo中,该问题将得到解决。

您可以在此处关注这种情况:https://github.com/expo/expo/issues/2813