向我的UIView(View_0)添加背景(图像)后,我希望实现一个按钮来删除相同的背景。如何重置UIView的背景
我该怎么办?我试图设置一个不同的图像作为View_0的背景,但这不起作用(我怀疑这个背景设置在“图像”后面)。
我不想使用
[View_0 removeFromSuperview];
,因为我需要View_0仍然在那里为其他目的....
//Create an ImageView
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 940, 422)];;
//Add the ImageView as the background of the View_0
[View_0 addSubview:image];
//Move custom image behind View
[View_0 sendSubviewToBack: image];
//Failed attempt to remove the background....
View_0.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"defaultImage.PNG"]];
它的确如此!非常感谢! – jeddi 2012-07-26 10:58:46
这是因为您完全删除图像。只需保留它们并设置imageview.hidden = YES当你不需要一个。 – IronManGill 2012-07-26 15:06:30