크로스 플랫폼/React-Native <JSX>

[React-Native/오픈소스활동] Modal이 전체 화면을 덮도록 구현하는 방법

TaeGyeong Lee 2023. 8. 23. 00:04

 

개요

안드로이드에서 React-Native 앱 개발 중 Modal 사용 시 상단 StatusBar를 덮지 않는 문제를 제시

 

문제 분석

 

문제 조치

해결 방법 안내 및 스크린샷 첨부

 

소스 코드

statusBarTranslucent 속성을 적용한 예제

import React, {useState} from 'react';
import {Text, View, Modal} from 'react-native';

export default function App() {
  return (
    <View style={{justifyContent: 'center', alignItems: 'center', flex: 1}}>
      <Text>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed volutpat
        lacus in massa eleifend blandit. Donec sit amet ipsum sed odio bibendum
        facilisis a eu lorem. Fusce consequat felis at massa rhoncus, a faucibus
        sapien interdum.
        <Modal transparent visible={true} statusBarTranslucent={true}>
          <View
            style={{
              width: '100%',
              height: '100%',
              backgroundColor: 'red',
            }}></View>
        </Modal>
      </Text>
    </View>
  );
}

 

관련 링크

 

Modal push elements down when it's open ANDROID · Issue #37418 · facebook/react-native

Description I create a tooltip component, but when i open the modal with the property "transparent", the elements are pushed down only happend in Android. In iOS work's well. React Native Version 0...

github.com

 

Modal · React Native

The Modal component is a basic way to present content above an enclosing view.

reactnative.dev