I have a screen called HomeScreen which implements UIViewController. I wish to use a background image for this screen. Is there an event that I can override to set this background image in the HomeScreen.cs file?
try setting the BackgroundColor of your View
myview.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("myimage.png"));
I voted up for the other answers, however today IPhone has different sizes and the correct way to load the image is using UIImage.FromBundle
method:
Here is the assert catalog in the project:
To manage the images:
public override void ViewDidLoad()
{
base.ViewDidLoad();
// replace "name" with the desired name in the asset catalog
this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("name"));
}
Try adding something like the following to your MyViewNameViewController.cs:
public override void ViewDidLoad()
{
base.ViewDidLoad();
this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("splash.png"));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With