关闭

自定义弹框遮住导航和Tabbar

794人阅读 评论(0) 收藏 举报
分类:

创建弹框:

/* 遮罩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;


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:271147次
    • 积分:4346
    • 等级:
    • 排名:第7268名
    • 原创:202篇
    • 转载:29篇
    • 译文:0篇
    • 评论:26条
    最新评论