赞
踩
最近公司忙,没来得及写博客,补发一篇UIView模糊处理的小技巧,希望大家能用得上
//定义毛玻璃效果
- UIBlurEffect * blur = [UIBlurEffecteffectWithStyle:UIBlurEffectStyleDark];
- UIVisualEffectView * effe = [[UIVisualEffectViewalloc]initWithEffect:blur];
- effe.frame =CGRectMake(50,90, self.view.frame.size.width - 100, 400);
// 把要添加的视图加到毛玻璃上
- UIButton * btn = [[UIButtonalloc]initWithFrame:CGRectMake(50,50, 100,100)];
- btn.backgroundColor = [UIColorredColor];
- [effeaddSubview:btn];
- [self.viewaddSubview:effe];
效果是枚举,有三种:
UIBlurEffectStyleExtraLight UIBlurEffectStyleLight UIBlurEffectStyleDark
之后还有你想把你的图片模糊也可以这样添加:
// 定义需要毛玻璃化的图片
- UIImageView * image = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"2.png"]];
- image.frame =CGRectMake(100,100, 100,100);
// 定义毛玻璃效果
- UIBlurEffect * blur = [UIBlurEffecteffectWithStyle:UIBlurEffectStyleDark];
- UIVisualEffectView * effe = [[UIVisualEffectViewalloc]initWithEffect:blur];
- effe.frame =CGRectMake(50,90, self.view.frame.size.width - 100, 400);
- [image addSubview:effe];
- [self.viewaddSubview:image];
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。