3
votes

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

iPad

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?

1
Better: 1536 x 2008 [email protected], and 2048 x 1496 [email protected]Caveman

1 Answers

3
votes

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);

        }
    }
}