自定义弹框遮住导航和Tabbar

创建弹框:

/* 遮罩window */
@property(nonatomic,strong)UIWindow *coverWindow;
/* 弹框 */
@property(nonatomic,strong)UIView *alertView;

-(UIView *)alertView
{
    if (!_alertView) {
        _alertView = [[UIView alloc]initWithFrame:CGRectMake(50, (kScreenHeight-150)*0.5, kScreenWidth-100, 150)];
        _coverWindow = [[UIWindow alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
        _coverWindow.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
        
        _alertView.clipsToBounds = YES;
        _alertView.layer.cornerRadius = 4;
        [_coverWindow addSubview:_alertView];
        _coverWindow.windowLevel = UIWindowLevelNormal;
        _coverWindow.hidden = YES;
        [[UIApplication sharedApplication].keyWindow addSubview:_coverWindow];
    }
    return _alertView;
}



显示弹框

self.alertView.hidden = NO;
        self.coverWindow.hidden = NO;

隐藏弹框

self.alertView.hidden = YES;
    self.coverWindow.hidden = YES;

自定义弹框遮住导航和Tabbar_第1张图片

你可能感兴趣的:(iOS)