Avoid status bar overlap on all screens

前端 未结 2 1081
误落风尘
误落风尘 2021-01-01 23:37

I want all screens on my app to appear below the status bar on both iOS and Android, so I\'d either have to add a StatusBar component or a paddingTop

2条回答
  •  我在风中等你
    2021-01-01 23:50

    Step 1: Import Platform and StatusBar

    import { Platform, StatusBar} from 'react-native';
    

    Step 2: Add this style in parent View

    paddingTop: Platform.OS === 'android' ? StatusBar.currentHeight : 0 
    

    Full Code:

    import React, { Component } from 'react';
        import {
          Text, View,
          Platform, StatusBar
        } from 'react-native';
    
        export default class App extends Component {
          render() {
            return (
              
                This is Text
              
            );
          }
        }
    

提交回复
热议问题