2

I am building an application in Xamarin.Forms, on the iOS app I want the status bar color to be white. Here is what I have so far:

App.cs

public App()
{
    NavigationPage _navigationPage = new NavigationPage(new RootPage());

    MainPage = _navigationPage;
}

3 Answers 3

7

After a recent Xamarin update you are now able to do this by setting the BarTextColorProperty,

_navigationPage.SetValue(NavigationPage.BarTextColorProperty, Color.White);

However just like in pvnak's answer you still need to add the following to your Info.plist

  • Property: UIViewControllerBasedStatusBarAppearance
  • Type: boolean
  • Value: No
3

Instead of using a custom renderer, you can set the status bar color globally with this approach:

Add the following property and value in your info.plist:

  • Property: UIViewControllerBasedStatusBarAppearance
  • Type: boolean
  • Value: No

Update the AppDelegate.cs in the iOS project with this line of code:

UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.LightContent, false);
3
  • 3
    Deprecated in iOS 9 Jun 16, 2016 at 10:30
  • Thanks for the heads up!
    – pnavk
    Jun 28, 2016 at 15:38
  • 1
    Or you do everything in info.plist: <key>UIViewControllerBasedStatusBarAppearance</key> <false/> <key>UIStatusBarStyle</key> <string>UIStatusBarStyleLightContent</string>
    – testing
    Sep 5, 2016 at 8:51
0

globaly change status bar text color and background color for ios

in App.xaml.cs:

var page = new NavigationPage(new MainPage()) { BarTextColor = Color.White };

in Info.plist:

<key>UIViewControllerBasedStatusBarAppearance</key>
          <false/>

and changing background color in AppDelegate.cs => override bool FinishedLaunching(...):

var statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
     if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
     {
         statusBar.BackgroundColor = UIColor.Black;
     }

and set padding top = 20 on every page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.