Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 无法在UIView的背景中设置图像?_Iphone_Objective C - Fatal编程技术网

Iphone 无法在UIView的背景中设置图像?

Iphone 无法在UIView的背景中设置图像?,iphone,objective-c,Iphone,Objective C,我试图把图像放在UIView的背景中。 问题是我的viewsubView位于主视图内。类: @interface abc : UIView { ....... } 在类中定义子视图: IBOutlet UIView* subView; 将子视图的背景图像设置为: UIColor* bgrColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed: backgroundImageName]]; subView.backgr

我试图把图像放在UIView的背景中。 问题是我的viewsubView位于主视图内。

类:

@interface abc : UIView {
.......
}
在类中定义子视图:

IBOutlet UIView* subView;
将子视图的背景图像设置为:

UIColor* bgrColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed: backgroundImageName]];
subView.backgroundColor = bgrColor;
最后,将子视图添加到视图中

[self.view addSubView:subView];
这很简单:

yourSubView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"BackgroundImage.png"]];