iOS 实现图片高斯模糊效果

效果图
iOS 实现图片高斯模糊效果_第1张图片
用到了 UIVisualEffectView

实现代码

- (UIVisualEffectView *)bgEffectView{
    if(!_bgEffectView){
        UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
        _bgEffectView = [[UIVisualEffectView alloc] initWithEffect:blur];
    }
    return _bgEffectView;
}

将 bgEffectView 盖到imageview上面即可

- (UIImageView *)bannerView
{
    if (!_bannerView) {
        _bannerView = [[UIImageView alloc] init];
        _bannerView.backgroundColor = [UIColor redColor];
    }
    return _bannerView;
}

- (UIVisualEffectView *)bgEffectView{
    if(!_bgEffectView){
        UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
        _bgEffectView = [[UIVisualEffectView alloc] initWithEffect:blur];
    }
    return _bgEffectView;
}


   [self addSubview:self.bannerView];
    [self addSubview:self.bgEffectView];

你可能感兴趣的:(ios)