如何在启动画面 Xamarin 中删除额外的 NavigationBar

How to remove extra NavigationBar in splash screen Xamarin

我正在构建 Xamarin CrossPlatform 应用程序!

我在我的应用程序中添加了一个启动画面,它工作正常,但问题是它在顶部给我一个额外的导航栏,我不想在我的应用程序中出现 MainPage

截图:

这是我的启动画面代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Last_MSPL.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class SplashPage : ContentPage
    {
        Image splashImage;


        public SplashPage()
        {
            NavigationPage.SetHasNavigationBar(this, false);

            var sub = new AbsoluteLayout();
            splashImage = new Image
            {
                Source = "truck.png",
                WidthRequest = 300,
                HeightRequest = 300
            };
            AbsoluteLayout.SetLayoutFlags(splashImage,
               AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(splashImage,
             new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));

            sub.Children.Add(splashImage);

            this.BackgroundColor = Color.FromHex("#FFF");
            this.Content = sub;
        }


        protected override async void OnAppearing()
        {
            base.OnAppearing();

            await splashImage.ScaleTo(1, 500); //Time-consuming processes such as initialization
            await splashImage.ScaleTo(0.9,1800, Easing.CubicInOut);
            //await splashImage.ScaleTo(0, 1600, Easing.Linear);
            Application.Current.MainPage = new NavigationPage(new MainPage());    //After loading  MainPage it gets Navigated to our new Page
        }

    }
}

如果主页是主要细节,那么只需替换 Application.Current.MainPage = new MainPage(); 不需要 Application.Current.MainPage = new NavigationPage(new MainPage());

可能是因为它在顶部为您提供了额外的导航栏。