0

I'm creating an app in React Native that uses react-navigation.

I have some views that animate off the screen towards the top of the screen. While animating, the view goes behind the react-navigation navigation header. It goes behind the iOS status bar, but the status bar is translucent, so it shows the status bar text on top of the view. The status bar is no longer white, but the color of the view under it.

This doesn't look right and I would like the status bar to be always on top and not translucent. What is the best way to go about this?

2 Answers 2

1

I was finally able to avoid content overlapping the status bar by placing this element in my topmost container:

<View 
    style = {{
        height: 20, 
        width: width, 
        backgroundColor: 'white', 
        zIndex: 3, 
        position: 'absolute', 
        top: 0,  
        left: 0,
    }} 
/>

The status bar still shows but animated content never overlaps it.

Sign up to request clarification or add additional context in comments.

Comments

0

It's because your react-navigation header has a elevation property, that works strangely (i think just in some cases) as a zIndex in Android, you probably can fix this by adding a higher zIndex to your iOS status bar than you have in the animation.

EDIT: Solved in How to set iOS status bar background color

8 Comments

Thanks for the advice. I tried changing the zIndex of the animated view like so: <View style = {{height: 232, zIndex: -5}}> But it still gives me the same problem.
Sorry, but is the animation showing over or under the status bar?
If the problem is it showing under, you can just create a position: relative view to be a parent of the absolute animation so it won't go under IOS translucent status bar.
The animation seems to go under the status bar text, but since the status bar is translucent, it shows the view underneath it, instead of the white color of the status bar.
I also attempted this, with no luck: <StatusBar style = {{zIndex: 99}} />
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.