iOS简单实现毛玻璃效果

iOS8之后有一个类 UIVisualEffectView

// 毛玻璃
    UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    img.userInteractionEnabled = YES;
    img.image = [UIImage imageNamed:@"effect"];
        [self.view addSubview:img];
//    UIBlurEffectStyleExtraLight,
//    UIBlurEffectStyleLight,
//    UIBlurEffectStyleDark
    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
    effectview.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
    effectview.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)];
    [effectview addGestureRecognizer:tap];
    effectview.alpha = 1.0; // 根据需要设置渲染的程度
    [self.view addSubview:effectview];
原文地址:https://www.cnblogs.com/xs514521/p/5644043.html