答案 0 :(得分:4)
您可以使用react-native新版本51中的SafeAreaView。
import {
...
SafeAreaView
} from 'react-native';
class Main extends React.Component {
render() {
return (
<SafeAreaView style={styles.safeArea}>
<App />
</SafeAreaView>
)
}
}
const styles = StyleSheet.create({
...,
safeArea: {
flex: 1,
backgroundColor: '#FF5236'
}
})
答案 1 :(得分:2)
请参阅:How to set iOS status bar background color in React Native?
import DeviceInfo from 'react-native-device-info';
// getModel: iPhone X
// getDeviceId: iPhone10,3
const ModelIphoneX = 'iPhone X';
// StatusBarHeight is where Carrier info and date display at top
// iPhone X has a cut-out in top of dispaly where sensor package is located.
// For iPhone X increase height so cut-out does not hide text
const StatusBarHeightIos = DeviceInfo.getModel() === ModelIphoneX ? 30 : 20;
const StatusBarHeight = Platform.OS === 'ios' ? StatusBarHeightIos : 0;
屏幕截图:左侧的iPhone X
答案 2 :(得分:1)
通过使用XCode将应用启动屏幕从图像资源更改为Storyboard来解决此问题。