Xaml erkennt die -568h
oder @2x
e.t.c für iOS nicht. Es wählt das Bild aus, das dem genauen Namen ohne Erweiterung entspricht. Es funktioniert auf Android, da alle Bilder denselben Namen haben und die Auflösungsordner unterschiedlich sind.
Als Workaround können Sie Bilder aus dem C# -Code festlegen, indem Sie die Höhe/Breite durch Überschreiben der OnSizeAllocated-Methode betrachten.
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
string BackGroundImgName = "myimage";
Device.OnPlatform(iOS:() =>
{
if (width >= 414)
// iPhone 6 Plus
this.BackgroundImage = BackGroundImgName + "[email protected]";
else if (width >= 375)
// iPhone 6
this.BackgroundImage = BackGroundImgName + "[email protected]";
else if (width >= 320 && height >= 500)
// iPhone 5
this.BackgroundImage = BackGroundImgName + "[email protected]";
else if (width >= 320)
// iPhone 4
this.BackgroundImage = BackGroundImgName + "@2x.png";
else
this.BackgroundImage = BackGroundImgName + ".png";
},
Android:() => { this.BackgroundImage = BackGroundImgName + ".png"; }
);
}