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?
我有一个名为HomeScreen的屏幕,它实现了UIViewController。我想在这个屏幕上使用背景图片。是否有可以覆盖的事件在HomeScreen.cs文件中设置此背景图像?
3 个解决方案
#1
13
try setting the BackgroundColor of your View
尝试设置View的BackgroundColor
myview.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("myimage.png"));
#2
4
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:
我投了其他答案,但今天IPhone有不同的大小,加载图像的正确方法是使用UIImage.FromBundle方法:
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"));
}
#3
1
Try adding something like the following to your MyViewNameViewController.cs:
尝试在MyViewNameViewController.cs中添加以下内容:
public override void ViewDidLoad()
{
base.ViewDidLoad();
this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("splash.png"));
}
#1
13
try setting the BackgroundColor of your View
尝试设置View的BackgroundColor
myview.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("myimage.png"));
#2
4
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:
我投了其他答案,但今天IPhone有不同的大小,加载图像的正确方法是使用UIImage.FromBundle方法:
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"));
}
#3
1
Try adding something like the following to your MyViewNameViewController.cs:
尝试在MyViewNameViewController.cs中添加以下内容:
public override void ViewDidLoad()
{
base.ViewDidLoad();
this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("splash.png"));
}