简体   繁体   English

带有 MAUI 版本的启动画面

[英]Splash screen with version In MAUI

I am trying to make a splash screen in.Net MAUI that contains app version.我正在尝试在包含应用程序版本的 .Net MAUI 中制作启动画面。 I have looked for many examples but none of them shows how to customize splash screen with version or text.我已经查找了很多示例,但没有一个显示如何使用版本或文本自定义启动画面。 Is it possible in.Net MAUI.有没有可能在.Net MAUI. If there is an example or a way to add app verion with logo in.Net MAUI please let me know.如果有在 .Net MAUI 中添加带有徽标的应用程序版本的示例或方法,请告诉我。

Yes,you can create a ContentPage that acts as a Splash screen,just as FreakyAli said.是的,您可以创建一个充当启动画面的ContentPage ,就像 FreakyAli 所说的那样。

There is a sample code, you can refer to it.有一个示例代码,你可以参考它。

MySplashScreen.xaml我的启动画面.xaml

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="XamSample.MySplashScreen"
                          BackgroundColor="#000">

    <StackLayout HorizontalOptions="Center" VerticalOptions="Center" Padding="10">
        <Image Source="test.png" x:Name="imgLogo" HeightRequest="100" WidthRequest="100"
               Margin="5"/>
        <Label Text="WHATSAPP" FontSize="Large" TextColor="#f7f7f7" Margin="5"/>
    </StackLayout>
</ContentPage>

MySplashScreen.xaml.cs我的启动画面.xaml.cs

    public partial class MySplashScreen : ContentPage 
      {
            public MySplashScreen ()
            {
                  InitializeComponent ();
            NavigationPage.SetHasNavigationBar(this, false);
            LogoAnimation();
        }

        public async Task LogoAnimation()
        {
            imgLogo.Opacity = 0;
            await imgLogo.FadeTo(1, 3000);
            Application.Current.MainPage = new NavigationPage(new MainPage());
        }
    }

App.xaml.cs应用程序.xaml.cs

public partial class App : Application 
{
    public App()
    {
        InitializeComponent();

        MainPage = new DarkScreen();
    }
}

Note:笔记:

1.Here, I used FadeTo function to simulate the time delay. 1.在这里,我使用FadeTo函数来模拟时间延迟。 Of course, you can also use a Timer to acheve this.当然,您也可以使用Timer来实现这一点。

2.You can add a Label to display the version name to page MySplashScreen as needed. 2.可以根据需要在MySplashScreen页面添加一个显示版本名的Label

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM