教你几行代码实现图片的模糊效果

一张清楚的图片变的模糊了,也就是所谓的毛玻璃效果,通过查看图层可以发现,它只是在原有的图片上加了一个View,而这个View具有毛玻璃效果,

图层查看如下图所示:

最终效果图如下图:

1 1     // 创建图片
2 2     UIImageView *imgView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
3 3     imgView.image = [UIImage imageNamed:@"1"];
4 4     [self.view addSubview:imgView];
5 5     //添加模糊效果
6 6     UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
7 7     UIVisualEffectView *effectView = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
8 8     effectView.frame = [UIScreen mainScreen].bounds;
9 9     [imgView addSubview:effectView];
原文地址:https://www.cnblogs.com/liyy2015/p/5240364.html