我正在构建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
}
}
}
答案 0 :(得分:1)
如果主页是主要详细信息,则只需替换
Application.Current.MainPage = new MainPage();
不需要Application.Current.MainPage = new NavigationPage(new MainPage());
可能是因为它在顶部提供了额外的导航栏。