Search code examples
c#xamarinxamarin.formssplash-screen

IOS don't show logo in splash screen


I create a SplashPage.cs in my Xamarin App, code:

public class SplashPage : ContentPage
    {
        Image splashImage;

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

            var sub = new AbsoluteLayout();

            splashImage = new Image
            {
                Source = "logo.png",
                WidthRequest = 100,
                HeightRequest = 100
            };
            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("#ffff");
            this.Content = sub;
        }

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

            await splashImage.ScaleTo(1, 2000);
            await splashImage.ScaleTo(0.9, 1500, Easing.Linear);
            await splashImage.ScaleTo(150, 1200, Easing.Linear);

            Application.Current.MainPage = new NavigationPage(new LoginPage());

        }

    }

Then in App.xaml.cs

public App()
        {
            InitializeComponent();

            MainPage = new NavigationPage(new SplashPage());
        }

Directory in Android is Resources/drawable/logo.png Directory for IOS is Resources/logo.png

When I compile app in a android phone splash load correctly, but when I try to use in IOS it just no load my icon, only show empty page. I'm doing something wrong?


Solution

  • Yes,this is often the case when you are using images that are not formatted correctly or are very complex.And I've had similar problems before. Vector graphics are highly recommended in ios.

    I have tested this question, when i use a vector image , it worked properly both in ios and android.

    Note: You can try it using the following image.

    enter image description here