Core IOS Sample 3-3 展示全屏模态UIView

获得window
- 弹出的模态view覆盖了整个屏幕,这种UIView必须添加到window中。
UIWindow *window = self.view.window;
...
// 令overlayView捕获所有触摸事件,从而阻止这些事件到达下方的其他GUI
overlayView.userInteractionEnabled = YES;
...
[window addSubview:overlayView];弹出数秒后消失
[self performSelector:@selector(removeOverlay:) withObject:overlayView afterDelay:5.0f];即等待5s然后调用:
[self removeOverlay:overlayView];当然,removeOverlay方法就很简单了:
- (void)removeOverlay:(UIView *)overlayView
{
[overlayView removeFromSuperview];
}关于userInteractionEnabled
对于UIView该值默认为YES,在本例中若设置overlayView的userInteractionEnabled为NO效果是这样的:
