目录
毛玻璃效果介绍
设置毛玻璃效果我们可以理解成在在图片上加了一层模糊蒙版,如果不理解蒙版,可以理解成我们透过毛玻璃查来看图片
我们来看以下两张图片,图一为原图,图二为添加了毛玻璃效果的图片.
实现过程
- 加载图片,并创建imageView,将图片加载到imageView上(常规操作)
- 创建蒙版图层,大小设置与iamgeView或者image大小一致均可,也可以根据实际情况创建大小
- 设置蒙版图层的样式为UIBarStyleBlack
- 将蒙版图层加到imageView上
代码实现
/**
设置毛玻璃效果
*/
-(void)setUpToolBar{
//常规操作
UIImageView *imageV = [[UIImageView alloc]init];
imageV.frame = CGRectMake(50, 180, 300, 282);
imageV.image = [UIImage imageNamed:@"timg"];
//设置蒙版
UIToolbar *toolBar = [[UIToolbar alloc]init];
//设置蒙版尺寸
toolBar.frame = imageV.bounds;
//设置蒙版风格
toolBar.barStyle = UIBarStyleBlack;
//将蒙版添加到imageView上
[imageV