3

I am using xamarin.forms to develop an app. The app has screens with background images. So to have proper background's i referred to the ios documentation here with taking dimensions of the launch/splash screen into consideration as they are like background images, but this doesn't work. This is what i follow:

iPhone

  • 320 x 480 Default.png
  • 640 x 960 Default@2x.png
  • 640 x 1136 Default-568h@2x.png
  • 750 x 1334 Default-667h@2x.png
  • 1242 x 2208 Default-736h@3x.png
  • 2208 x 1242 Default-Landscape@3x.png

iPad

  • 768 x 1024 Default-Portrait.png
  • 1536 x 2048 Default-Portrait@2x.png
  • 1024 x 768 Default-Landscape.png
  • 2048 x 1536 Default-Landscape@2x.png

the images in iphone 6 (iOS 9.0) are repeating.

EDIT: I needed the naming convention and sizes for the image to be used as background images in xamarin.forms content page.

Any help on this sizes and naming?

RohitWagh
  • 1,709
  • 3
  • 21
  • 40

1 Answers1

3

I have also been struggling with this, it seems like the iPhone 6 (Plus) screens aren't implemented in Xamarin.Forms.

LaunchScreen

This is probably because Apple themselves are recommending the use of Storyboards and/or XIB files for your LaunchScreen as of iPhone 6, or better yet iOS 8.

I quote:

In iOS 8 and later, you can create a XIB or storyboard file instead of a static launch image. When you create a launch file in Interface Builder, you use size classes to define different layouts for different display environments and you use Auto Layout to make minor adjustments. Using size classes and Auto Layout means that you can create a single launch file that looks good on all devices and display environments.

This, in fact, is supported by Xamarin.Forms.

Just create a StoryBoard in your Resources file, configure your splash screen and select it as LaunchScreen in your info.plist file.

info.plist editor in Xamarin Studio

Advantage is that it works for all devices.

Background images

As for background images, according to the Xamarin iOS documentation this should work. If it doesn't for Xamarin.Forms you should probably report a bug. Meanwhile you could use a custom renderer like underneath, taken from the Xamarin Forums or check another suggestion from that thread:

[assembly: ExportRenderer(typeof(InfoPage), typeof(InfoPage_iOS))]

namespace Oxaco_BBC.iOS
{
    public class InfoPage_iOS : PageRenderer
    {
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(false);

            UIGraphics.BeginImageContext(this.View.Frame.Size);
            UIImage i = UIImage.FromFile("Background.png");
            i = i.Scale(this.View.Frame.Size);

            this.View.BackgroundColor = UIColor.FromPatternImage(i);

        }
    }
}
Gerald Versluis
  • 21,913
  • 5
  • 52
  • 75
  • Life saver! In my case I needed to get the background from the bundle https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/images-icons/displaying-an-image?tabs=windows#adding-images-to-an-asset-catalog-image-set – Justin Mar 17 '21 at 15:45