Iphone 无法在UIView的背景中设置图像?
我试图把图像放在UIView的背景中。 问题是我的viewsubView位于主视图内。类: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
@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"]];