1.实例化两个属性
- (UIBlurEffect *)effect
{
if (!_effect) {
_effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
}
return _effect;
}
- (UIVisualEffectView *)effectView
{
if (!_effectView) {
_effectView = [[UIVisualEffectView alloc] initWithEffect:self.effect];
_effectView.frame = CGRectMake(0, 0, self.bgImageView.width, self.bgImageView.height);
}
return _effectView;
}
2. bgImageView设置图片, 并把毛玻璃效果添加到需要显示的控件上
[self.bgImageView sd_setImageWithURL:[NSURL URLWithString:imgUrl]];
[self.bgImageView addSubview:self.effectView];
3. 这样就可以了(仅限iOS8以后的版本)