With the introduction of Page Sheets in iOS 13, there is a white background in my app that I cannot seem to be able to change (behind the white Page Sheet, and the grey top of the underlying page):
Obviously, for most apps a black background color would look much better.
While for ejected React Native apps, one could use:
https://github.com/johniak/react-native-root-view-background
I'm curious if anyone using managed Expo has figured out a way to deal with this. As I cannot find much complaints about this issue, other than:
https://github.com/expo/expo/issues/1563
There is an simple trick using navigator...
<NavigationContainer>
<Stack.Navigator
screenOptions={{
cardStyle: {
backgroundColor: 'Your_Color_Here'
}
}}
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen name="Register" component={RegisterScreen} />
</Stack.Navigator>
</NavigationContainer >
You can use cardStyle to change default white backgroundColor to your desire backgroundColor. I hope this answer helps use it works for me.
For anyone out there who's using #react-navigation and looking for a way to change the background color of the root view between tab changes: simply add backgroundColor prop to app.json:
"backgroundColor": "#000000",
Might work in other scenarios as well.
I guess you are using react-navigation 5.x with createNativeStackNavigator and then using presentation:"modal" in your screen options. I could not find a way to set a black background the on the root view with this type of navigator.
Here's what I ended up doing :
create a standard StackNavigator with createStackNavigator, with mode='modal' property.
put all my modals within this navigator at the root of my app with ...TransitionPresets.ModalPresentationIOS in my screen options. This mimics the behavior you are looking for, as createStackNavigator respects the backgroundColor property set in your app.json file for it's root view.
I came up with this solution after finding this Snack (https://snack.expo.io/#satya164/modal-presentation-style-in-react-navigation). This is far from perfect but the best I could do for now using managed Expo. With nesting navigators, I keep using createNativeStackNavigator for push navigators to get nice, native push transitions for anything other than modals.
Related
How do I display the dark mode icon while in Light mode on an iOS device? I have been searching this issue for months now and every post seems to come to dead end or the solutions just don't work. Using Xamarin 17.3 & VS 2022 and and developing an app for both Android & iOS. We have the Shell's background color (<Setter Property="Shell.BackgroundColor" Value="141B4D") which is a dark blue. The default, black icons (battery, time & etc.) don't show well with this background (its a company color and can't change it.) Android seems to handle this on its own and I didn't have to make any changes & the light icons show on the dark background in both Light & Dark modes. But on iOS in light mode the black icons display but cannot be seen. In dark mode the light icons show just fine.
Awhile back I tried a suggestion to to tell it, in the shared app, to use the dark mode icons in light mode.
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Dark=Black, Light=#141B4D}" />
<Setter Property="Shell.ForegroundColor" Value="{AppThemeBinding Dark=White, Light=White}" />
But this doesn't work. So I really need some help in solving this. And if this is not the proper way to handle this a good alternative is welcomed.
Thanks
Based on your code, seems that you just want the text or icon in statusbar to be white if i understand correctly. So a simple way to achieve is to add the following code in AppDelegate:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
...
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
return base.FinishedLaunching(app, options);
}
Also, you have to add one key in info.plist
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Note: in Property List Editor, it will show View controller-based status bar appearance
Then in dark blue background, you can also see white icon. The following picture is in light mode.
Hope it works for you.
I seem to have some troubles with the TextColor of my Entry on iOS when Dark Mode is enabled.
Whenever I set the Entry's Enabled state to false, the TextColor turns white and it's not possible to change.
I used the following simple code to reproduce this.
Page.xaml
<Entry x:Name="TestEntry" />
Page.xaml.cs
public OnboardingPage()
{
InitializeComponent();
TestEntry.Text = "Testo";
TestEntry.TextColor = Color.Blue;
TestEntry.IsEnabled = false;
}
I am currently using the latest version of Xamarin.Forms. (4.4.0.991640)
Does anybody have an idea what's going wrong here? I don't think this is expected behavior..
Thanks in advance!
In the meanwhile I have found the fix necessary to my question.
Apparently the EntryRenderer on iOS uses uses the default color when legacy color management is enabled and the Entry is disabled. Setting the legacyColorManagement to False on the Entry solves this issue.
XF check for legacycolormanagement
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Extensions/VisualElementExtensions.cs#L15
XF check for TextColor of the Entry
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/EntryRenderer.cs#L272
I've added following code to my *Page.xaml and now the colors are rendering correctly:
*Page.xaml
<ContentPage xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
...>
<Entry ios:VisualElement.IsLegacyColorModeEnabled="False"
.../>
The reason that is happening because of how iOS works with the dark mode for you to handle this you have to add the following in your Info.Plist
<key>UIUserInterfaceStyle</key>
<string>Light</string>
What this will do is stop your app from changing anything when Dark mode is turned on i.e. it is sort of an opt-out
Goodluck
Feel free to get back if you have questions
I'm developing an app using React Native, I've been asked to set the text color of the status bar in white.
I used the StatusBar component with the property barStyle="light-content" and it works pretty well on Android but not on iOS, the text color is still black.
I did some research about it but I couldn't find anything helpful. I even tried to select the Light Status bar style on XCode like the following picture shows but it still doesn't work
I solved the problem!
I use this code in Index page and set the text color to white:
<StatusBar barStyle="light-content" translucent={true} />
Try putting this code in didFinishLaunchingWithOptions in your AppDelegate file.
UIApplication.shared.statusBarStyle = .lightContent
Objective c
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
and in your info.plist file set UIViewControllerBasedStatusBarAppearance to NO
I solved my problem !
The issue came from a React Native library called React Native Navbar, it was taking control of the status bar as well, I had to setup the 'light-content' property in that component.
<StatusBar backgroundColor={"white"} barStyle="dark-content" />
how can i change the theme or default background color for ios.. it's conflicting with my background image. I'd like to set it to transparent.. Thanks
First let's understand how scenes in react-native-router-flux works. When you define them in your navigator, like below,
<Scene sceneStyle={{marginTop: 64}} title="Home" key="home" component={Home} />
You simply say that, my content should render below the pre defined navbar. Which can be 54 or 64 depending on your OS. So when you use Router,
<Router navigationBarStyle={{backgroundColor: 'transparent'}}>
and add navigationBarStyle to every Scene you have by introducing that line, you almost forgot what you've done above, setting your Scene to align itself some margin below the navigationBar. Therefore you see nothing (white space) in your simulator.
In order to have what you need, do this where you want your image to appear full screen with navigation controls:
Actions.refresh({
key: 'home',
navigationBarStyle: {backgroundColor: 'transparent'},
sceneStyle: {marginTop: 0},
});
Or you can introduce this settings in your Scene component where you define it.
I tested this solution and it works on iOS, can't tell the same for Android, so please back up your code before making changes. You can further customize it to remove borderBottom line.
I want to keep the keyboard displayed at the bottom by default without using a text input which the user needs to tap.
I need to keep the keyboard at the bottom at all times.
Then I need to listen to the events of the keyboard.
How can I do this?
The workaround I implemented was adding an invisible text box somewhere on the screen and then set it as focused manually.
Just in case someone else might stumble upon this, OP's self answer works. In order to set focus manually, you'll need to get the ref to the hidden input.
<TextInput
ref={input => (this.textinput = input)}
style={{ display: 'none' }}
/>
then elsewhere in the code, you focus manually by
if (this.textinput) {
this.textinput.focus();
}
This answer is way too late to do the OP any good, but for others:
You can't do this. In iOS, the operating system, keyboards simply don't/can't work this way. iOS never shows a keyboard without an active text input focus, and there is no way for even a native iOS app to override this OS-level behavior. The OS itself prevents this from happening.