向我的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