Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms iOS status bar text color

I am unable to change the status bar text color of my Xamarin Forms iOS app to white. I have change in my info.plist as follow:

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

Yet the color still remain black.. Is there another way to change the status bar text color?

like image 457
Huby03 Avatar asked May 29 '17 14:05

Huby03


People also ask

How do I change the color of a status bar in Swift?

Open your info. plist and set UIViewControllerBasedStatusBarAppearance to false . In the first function in AppDelegate. swift , which contains didFinishLaunchingWithOptions , set the color you want.

How do I use xamarin community toolkit?

Setup Xamarin Community ToolkitOpen an existing project, or create a new project using the Blank Forms App template. In the Solution Explorer panel, right click on your project name and select Manage NuGet Packages. Search for Xamarin. CommunityToolkit, and choose the desired NuGet Package from the list.

What is Shell in xamarin forms?

Xamarin. Forms Shell reduces the complexity of mobile application development by providing the fundamental features that most mobile applications require, including: A single place to describe the visual hierarchy of an application. A common navigation user experience.


2 Answers

In Xamarin.Forms, there are three things you need to do to achieve white text in the iOS Status Bar. I've also posted a sample Xamarin.Forms app below that uses white text in the iOS Status Bar.

1. Update the Info.plist

In Info.plist, add the Boolean Property View controller-based status bar appearance and set its value to No

enter image description here

2. Use a NavigationPage & Set the Navigation Bar Text Color to White

In the Application class (typically App.cs), the MainPage must be a NavigationPage, and the BarTextColor must be set to Color.White enter image description here

3. Clean & Rebuild the App

Sometimes the compiler doesn't update the Status Bar Color until you Clean and Rebuild the app, so after making the changes in steps 1 & 2, clean the app and rebuild it. enter image description here

Sample App

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

like image 99
Brandon Minnick Avatar answered Oct 11 '22 23:10

Brandon Minnick


The only way to change status bar in IOS for me was 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);
}
like image 38
Renzo Ciot Avatar answered Oct 12 '22 01:10

Renzo Ciot