0
我有按鈕,使覆蓋有標籤和X按鈕就可以了:iOS:如何從它的子視圖中刪除重疊?
- (IBAction)taptaxi:(id)sender {
UIView *overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
overlay.backgroundColor = [UIColor colorWithWhite:0 alpha:.7];
UILabel *waiting = [[[UILabel alloc] initWithFrame:CGRectMake(50, 210, 250, 30)] autorelease];
waiting.text = @"Waiting for cab response...";
waiting.textColor = [UIColor whiteColor];
waiting.backgroundColor = [UIColor clearColor];
waiting.font = [UIFont systemFontOfSize:14];
UIButton *stoprequest = [[UIButton alloc] initWithFrame:CGRectMake(225, 219, 13, 13)];
UIImage *srbackground = [[UIImage imageNamed:@"iks.png"] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[stoprequest setBackgroundImage:srbackground forState:UIControlStateNormal];
[stoprequest addTarget: self action: @selector(stopRequestMethod:) forControlEvents: UIControlEventTouchUpInside];
[self.view.window addSubview:overlay];
[overlay addSubview:waiting];
[overlay addSubview:stoprequest];
}
- (void)stopRequestMethod: (id)sender
{
}
問題是,如何隱藏/帶標籤和按鈕刪除疊加,當我在X butoon(stopRequestMethod)自來水?
發行覆蓋你增加一條,作爲子視圖後。您可能會考慮設置覆蓋層的隱藏屬性,而不是調用removeFromSuperview,以跳過在需要時重複初始化覆蓋層的過程。 – 2011-04-22 22:08:28