点击弹出覆盖全屏的灰色

来源:互联网 发布:yum安装ipk 编辑:程序博客网 时间:2024/05/16 15:17

理想效果如下:


初步实现:


正常设置
   //设置整个灰色的背景视图    UIView *backgroundView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];    backgroundView.backgroundColor = [UIColor colorWithWhite:0.8 alpha:0.8];    [self.view addSubview:backgroundView];


发现视图并没有正确的覆盖整个屏幕



后来才发现  需要在 View 的后面加上 Window  这样涉及到的效果就是整个屏幕了


//设置整个灰色的背景视图    UIView *backgroundView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];    backgroundView.backgroundColor = [UIColor colorWithWhite:0.8 alpha:0.8];    [self.view.window addSubview:backgroundView];


更多精彩文章,尽在我的公众号.


0 0
原创粉丝点击