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

 

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

图层查看以下图所示:code

 

最终效果图以下图:blog

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];
相关文章
相关标签/搜索