Reputation: 7684
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?
Upvotes: 10
Views: 16028
Reputation: 8725
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"));
}
Upvotes: 4
Reputation: 11
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"));
}
Upvotes: 1
Reputation: 89117
try setting the BackgroundColor of your View
myview.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("myimage.png"));
Upvotes: 13