添加蒙层:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; [view setTag:108]; [view setBackgroundColor:[UIColor blackColor]]; [view setAlpha:0.5]; [self.view addSubview:view];
删除
UIView *view = (UIView*)[self.view viewWithTag:108]; [view removeFromSuperview];
这个蒙层是会挡住你下面的view的,如果有button这些事件的话,则无法触发,解决的办法是:关闭view的userinteraction。
[view setUserInteractionEnabled:NO];