Reputation: 2045
I know there are other topics on this, but they don't answer my problem.
For Android, the background image works fine.
BackgroundImage = Device.OnPlatform("Resources/[email protected]",
"Drawable/HTMobile.png",
"Images/HTMobile.png");
For iOS, I can't get it to work.
In iOS, the background image, in any of the scenarios above, just shows a white screen ontop of all the CustomContentPage controls. I comment out the background line of code, and my page shows normally, with all controls and navigations links...
With the following code (no 'Resouces' folder), the page shows normally, but no image...
BackgroundImage = Device.OnPlatform("[email protected]",
"Drawable/HTMobile.png",
"Images/HTMobile.png");
How do you set the background image in iOS? For this answer, I need to know the following:
EDIT
ContentPage.BackgroundImage is of type FileImageSource - meaning the correct resolution is loaded automatically; therefore the call should be...
BackgroundImage = Device.OnPlatform("HTbg.png",
"Drawable/HTMobile.png",
"Images/HTMobile.png");
But this still doesn't work. I'll add in the 4-inch image version and see if that helps...
Upvotes: 3
Views: 5849
Reputation: 101
This problem on IOS is solved by adding the required image to an IOS asset catalog. Xamarin.Forms WILL NOT load an image into the BackgroundImage property when it is located in the Resources folder as for versions of IOS pre 7. This might save someone some time.
Upvotes: 5