[native-stack] iOS 13 Style Modal Has White Background instead of Black
See original GitHub issueMoved 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.
Expected Behavior
- What do you expect should be happening? The status bar text should turn white and the background should be black:
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:
- Created 4 years ago
- Reactions:14
- Comments:14 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Setting up at navigator level with cardOverlayEnabled set to true is getting the right background colour with expo sdk37:
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:
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)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
toYES
. The reason why it is set toNO
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 toYES
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.