rn ios安全可视区域内渲染内容(iphoneX等设备)

1、引入
	import { StyleSheet, Text, SafeAreaView } from 'react-native';
	
2、使用
	设置 SafeAreaView 的样式,flex:1即可
    <SafeAreaView style={styles.container}>
      <Text>Page content</Text>
    </SafeAreaView>

代码示例:

import React from 'react';
import { StyleSheet, Text, SafeAreaView } from 'react-native';

const App = () => {
  return (
    <SafeAreaView style={styles.container}>
      <Text>Page content</Text>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default App;

猜你喜欢

转载自blog.csdn.net/weixin_43294560/article/details/108216796
RN
今日推荐