且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Xamarin Forms Master Detail Page主页隐藏导航栏

更新时间:2023-01-05 18:19:37

对于android实现,请将以下内容添加到您的MainActivity.cs中:

For the android implementation, add the following to your MainActivity.cs:

global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);

对于iOS,该过程需要自定义渲染器,但这确实很基本:

For iOS, the process requires a custom renderer, but it's really basic:

public class iOSCustomMobilePageRenderer : PageRenderer
{
    public override void ViewWillAppear(bool animated) {
        base.ViewWillAppear(animated);


        if (ViewController != null && ViewController.ParentViewController != null && ViewController.ParentViewController.NavigationController != null) {

            if (ViewController.ParentViewController.NavigationController.NavigationBar != null)
                ViewController.ParentViewController.NavigationController.SetNavigationBarHidden(true, false);
        }
    }
}