iOS添加遮罩层

本文介绍了在iOS中添加遮罩层的方法,通过在主界面UIView下方添加一个用于遮挡的UIView,以阻止用户交互,待操作完成后移除遮罩层。实现代码包括如何添加和移除遮罩层视图。
摘要由CSDN通过智能技术生成

添加遮罩层的原理是在一个可以操作的UIView下面有另一个UIView,下边的UIView的作用是遮挡住页面,使其无法进行操作,直到前一个界面的操作结束,然后直接将后一个UIView移除,代码如下:
[UIView animateWithDuration:0.4 animations:^{

    int iconWidth=delegate.currentWidth/2;
    UIView *view=[[UIView alloc]initWithFrame:CGRectMake(iconWidth-60,140,150,105 )];
    [view setBackgroundColor:[UIColor colorWithRed:255.f/255.f green:255.f/255.f blue:255.f/255.f alpha:1]];
    view.layer.cornerRadius=10;
    view.backgroundColor = [UIColor colorWithRed:255. green:55. blue:255. alpha:0.89f];
    view.layer.borderColor = [[UIColor lightGrayColor] CGColor];
    view.layer.borderWidth = 2.0f;
    //view.layer.cornerRadius = 10.0f;
    view.clipsToBounds = YES;

    view1 = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    //view1.backgroundColor = [UIColor colorWithRed:.255 green:.255 blue:.0 alpha:.255];
    [view1 setBackgroundColor:[UIColor whiteColor]];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值