Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hidden StatusBar in Expo React Native App Leaves Whitespace

In our Expo React Native app, the status bar currently shown on all the app's screens. However, one screen Welcome needs to have the status bar hidden.

In the Welcome screen, dropping in react-native's StatusBar component with hidden props set to true hides the status bar (on a physical iPhone) but leaves behind a white region.

Problem: This white region where the status bar used to be, should be transparent or removed to show the background image that is covering the rest of the screen.

How can we achieve this?

Before hiding

enter image description here

After hiding

Note: Its hard to see the white region on the white background of Stack Overflow

enter image description here

Routes/index.js

import { createStackNavigator, createSwitchNavigation } from 'react-navigation';

...

const AuthStack = createStackNavigator({
    Welcome: WelcomeScreen,
    Login: LoginScreen,
}, {
    headerMode: 'none',
})

...

Welcome.js

import React, { Component } from 'react';
import { View, ImageBackground, StatusBar } from 'react-native';
import { SafeAreaView } from 'react-navigation';

export class WelcomeScreen extends Component {

    render() {
        return (
            <View>
                <StatusBar hidden={true} />
                <SafeAreaView style={{height: '100%'}}>
                    <Layout style={{flex:1, justifyContent: 'center', alignItems: 'center'}}>
                        <ImageBackground source={myBackgroundImage} style={{width: '100%', height: '100%'}}>

...

Using

like image 784
Nyxynyx Avatar asked Nov 17 '22 03:11

Nyxynyx


1 Answers

This should fix the issue:

Replace

<StatusBar hidden={true} />

With

<StatusBar backgroundColor={'transparent'} translucent/>
like image 96
mualz Avatar answered Jan 08 '23 03:01

mualz