I have been testing my application on an iPhone X via iOS Simulator. I would like to know how I can recolour the black notch to the same color as my application theme.
Here's the current implementation:
How do I change the black bar to blue, matching my theme?
I have been testing my application on an iPhone X via iOS Simulator. I would like to know how I can recolour the black notch to the same color as my application theme.
Here's the current implementation:
How do I change the black bar to blue, matching my theme?
Share Improve this question asked Sep 21, 2017 at 9:42 DanDan 8,8149 gold badges46 silver badges82 bronze badges 3- If your intention is to color the status bar (the area where time and battery indicators are shown) then this question might be of help. I am deleting my current answer as it is not relevant – Ramesh Commented Sep 21, 2017 at 11:19
- Dan, take a look at my answer here stackoverflow./questions/46318395/… Hopefully it'll address your issue (bottom part relates to CSS) – Adrian Commented Sep 22, 2017 at 11:25
- The answer can be found here: stackoverflow./questions/39297291/… – Ed of the Mountain Commented Oct 31, 2017 at 21:16
3 Answers
Reset to default 10You can simply use SafeAreaView from react-native new version 51.
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'
}
})
See: How to set iOS status bar background color in React Native?
- For an iPhone X, the increase StatusBarHeightIos from 20 to 30
- I use react-native-device-info to detect device
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;
Screenshot: iPhone X on left
This is fixed by changing the app launch screen from image assets to a Storyboard, using XCode.