1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-16 13:38:02 +00:00

Add Avoid The Notch With SafeAreaView as the first react_native til

This commit is contained in:
jbranchaud
2018-04-28 12:09:00 -05:00
parent 0120e9c63a
commit db532b996a
2 changed files with 34 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
# Avoid The Notch With SafeAreaView
iOS devices, especially the iPhone X, have areas of the screen that are cut
off in ways that present quite a challenge to developers. One of the easiest
ways to deal with rounded corners and the notch when developing for iOS is
to avoid them all together.
> The purpose of `SafeAreaView` is to render content within the safe area
> boundaries of a device.
```javascript
import { SafeAreaView, View, Text } from 'react-native';
const App = () => {
return (
<SafeAreaView style={{ flex: 1, backgroundColor: "#e6e6e6" }}>
<View>
<Text>Safely rendered in the visible area of the device!</Text>
</View>
</SafeAreaView>
);
}
```
The _unsafe_ area can be styled however you like and everything inside
`<SafeAreaView>` will be pushed into the visible area of the screen.
[source](https://facebook.github.io/react-native/docs/safeareaview.html)