Xamarin Forms iOS status bar text color
Solution 1
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
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
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.
Sample App
https://github.com/brminnick/SaveImageToDatabaseSampleApp/
Solution 2
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);
}
Solution 3
So what I did for changing status bar color and status bar text color is:
Info.plist
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<!--<key>UIStatusBarHidden</key>-->
<!--<true/>-->
AppDelegate
Inside function FinishedLaunching(), add 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 code below to change status bar text color to White.
<Style TargetType="{x:Type NavigationPage}">
<!--<Setter Property="BarBackgroundColor" Value="Black" />-->
<Setter Property="BarTextColor" Value="White" />
</Style>
Huby03
Updated on June 30, 2022Comments
-
Huby03 almost 2 years
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?