How to remove top bar from Xamarin.Forms (iOS)?

佐手、 提交于 2020-05-14 03:54:33

问题


How can I remove the top bar from iOS project of Xamarin.Forms? Where the time and "Carrier" word are

.. or at least measure its height?

Just to be sure.. I don't want to see battery, time... I want to hide the bar in the red rectangle:


回答1:


You can add this code on your AppDelegate.cs inside FinishedLaunching method after LoadApplication (new App ()); on iOS Project:

UIApplication.SharedApplication.StatusBarHidden = true;

also add this on your info.plist:

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



回答2:


  1. Go to Info.plist file in your iOS project
  2. Click Source and Hover on one of those lines and a (+) and (-) button will show up. Click the plus button to add new key
  3. Type in start with capital V and automatically the first choice will be View controller-based status bar appearance. Add that as the KEY.
  4. Set the VALUE to "No" Now you can still see the time alone
  5. Then Click again the plus button to add new key
  6. Now choose Status bar is initially hidden and add key "Yes"

In case of you want to hide programatically for each page. You have to create custom renderer for each Forms Page with UIViewController.

In UIViewController, you can override method like below

public partial class CustomViewController : UIViewController
{
      public override bool PrefersStatusBarHidden()
        {
            return true;
        } 
}



回答3:


Goto info.plist

Just check the HideStatusBar



来源:https://stackoverflow.com/questions/44511921/how-to-remove-top-bar-from-xamarin-forms-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!