dotnetco.de

Hide Status Bar in Xamarin Forms for iOS and Android

If you want to hide the status bar at the top of iOS and Android, here is the code to do it in Xamarin Forms.

iOS

Open your Info.plist and add the following lines:

  • Status bar is initially hidden – Type Boolean – Value Yes
  • View controller-based status bar appearance – Type Boolean – Value No

These 2 lines will add the following code to your info.plist:

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

Android

Open your MainActivity.cs and add these 2 lines in OnCreate:

Window.AddFlags(WindowManagerFlags.Fullscreen);
Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);

Now both iOS and Android should not have a status bar at the top anymore.

NavigationPages

Not directly related to the status bar, but probably you also want to remove the Navigation Bar at the top when navigation to next page. Just SetHasNavigationBar to false on your navigation page.

 public MyPage()
 {
     InitializeComponent();
     NavigationPage.SetHasNavigationBar(this, false);

 

Leave a Comment