question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[native-stack] iOS 13 Style Modal Has White Background instead of Black

See original GitHub issue

Moved from react-navigation/react-navigation#6791. Originally opened by @hammadj


Current Behavior

  • What code are you running and what is happening? Using a NativeStackNavigator and presenting a screen with stackPresentation: 'modal' results in the app having a white BG. Screen Recording 2020-02-06 at 12 15 20 AM

Expected Behavior

  • What do you expect should be happening? The status bar text should turn white and the background should be black: RPReplay_Final1580973117

How to reproduce

Using Expo SDK 36, with backgroundColor in app.json set to #000000 it still doesn’t work.

Here’s the code snippet:

const Stack = createNativeStackNavigator<NavScreenParams>();

export const HomeNavigator: React.FC = () => (
  <Stack.Navigator initialRouteName={Screen.HOME}>
    <Stack.Screen
      name={Screen.HOME}
      component={Home}
      options={{ title: 'Home', headerShown: false }}
    />
    <Stack.Screen
      name={Screen.PROFILE}
      component={ProfileNavigator}
      options={{ stackPresentation: 'modal' }}
    />
  </Stack.Navigator>
);

Your Environment

software version
iOS or Android iOS
@react-navigation/native 5.0.0
@react-navigation/native-stack 5.0.0
react-native-screens 2.0.0-beta.2
react-native https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz
expo 36.0.2
node 10.16.0
npm or yarn 1.16.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:14
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

15reactions
sbklcommented, May 19, 2020

Setting up at navigator level with cardOverlayEnabled set to true is getting the right background colour with expo sdk37:

<Stack.Navigator
    headerMode="none"
    mode="modal"
    screenOptions={{
        gestureEnabled: true,
        cardOverlayEnabled: true,
        ...TransitionPresets.ModalPresentationIOS,
    }}
>
    //Stack.Screens goes here
</Stack.Navigator>
5reactions
kmagieracommented, Mar 26, 2020

I’m currently working on exposing a way to customize status bar from stack header options. This is not ready yet and I’ll update here on the status.

In the meantime wanted to share some solutions you may try right now:

  1. The background color that you see under the new iOS 13 modal is the application window background. Apparently expo sets that to be white. If your app is ejected from expo (or use bare workflow) you should be able to change that in appdelegate by doing self.window.backgroundColor = [UIColor blackColor]; after the window is initialized. Note this will change the background for the whole app and won’t allow you to update that background at will (unless you write a native module to update it)

  2. The status bar color below the modal should be handled automatically by the system. However that behavior is likely disabled if you use standard react-native or expo project. To enable automatic handling of status bar color you’ll need to update Info.plist setting UIViewControllerBasedStatusBarAppearance to YES. The reason why it is set to NO is for the RN’s StatusBar module to work. The status bar module allows for overriding status bar style but it requires that option to be disabled. If you change it to YES you will no longer be able style the status bar using StatusBar module from react native. Flipping it to YES however will give you the exact effect as in the first post here where the status bar color animates as the modal opens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS 13 Style Modal Has White Background instead of Black
iOS 13 Style Modal Has White Background instead of Black #6791 ... META-DREAMER added bug package:native-stack labels on Feb 7, 2020.
Read more >
How do I modify the “deep” background when using an iOS 13 ...
It works and animates great, but I'd like the back-background to be black. In the screenshot below, I'm talking about the darkest grey...
Read more >
Themes - React Navigation
Customize the colors match your brand; Provide light and dark themes based on the ... On iOS 13+ and Android 10+, you can...
Read more >
How To Use Opacity and Transparency to Create a Modal in ...
When styling HTML with CSS, opacity can help soften a shadow, ... White modal box with a black background covering the rest of...
Read more >
How to set background color? | Apple Developer Forums
I have found a way to set the system background color using SwiftUI. It is pretty handy when you want the background color...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found