Xamarin Forms iOS Status Bar Text Color

I cannot change the color of the text in the status bar of my XAMAIN Forms iOS app to white. I changed my info.plist like this:

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

      

However, the color is still black. Is there any other way to change the color of the status bar text?

+12


source to share


4 answers


In Xamarin.Forms, there are three things you need to do to get white text on the iOS status bar. I also posted a sample Xamarin.Forms app that uses white text in the iOS status bar.

1. Update Info.plist

In Info.plist

add View controller-based status bar appearance

Boolean Property View controller-based status bar appearance

and set its valueNo

enter image description here

2. Use NavigationPage and set the text color of the navigation bar to white



The class Application

(usually App.cs

) MainPage

must be NavigationPage

, and BarTextColor

must be set toColor.White

enter image description here

3. Clean and restore the application

Sometimes the compiler won't update the status bar color until you clean and rebuild the app, so after making the changes in steps 1 and 2, clean the app and rebuild it. enter image description here

Sample Application

https://github.com/brminnick/SaveImageToDatabaseSampleApp/

+25


source


The only way to change the status bar in IOS for me is to use this code in FinishedLaunching in AppDelegate



public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    global::Xamarin.Forms.Forms.Init ();

    LoadApplication (.....);
    app.SetStatusBarStyle(UIStatusBarStyle.LightContent, true);

    return base.FinishedLaunching (app, options);
}

      

+1


source


Select NavigationBar

and change the property Style

to Black

.

enter image description here

0


source


So what I did to change the status bar color and status bar color:

Info.plist

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarHidden</key>
<true/>

      

AppDelegate

Inside the FinishedLaunching () function, add the code below:

UIView statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
if (statusBar != null && statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
{
    statusBar.BackgroundColor = Color.FromHex("#7f6550").ToUIColor(); // change to your desired color 
}

      

App.xaml

I added below code to change the status bar text color to White.

<Style TargetType="{x:Type NavigationPage}">
     <!--<Setter Property="BarBackgroundColor" Value="Black" />-->
     <Setter Property="BarTextColor" Value="White" />
</Style> 

      

0


source







All Articles