iOS高斯模糊实现
来源:互联网 发布:上海老程宝马 淘宝店 编辑:程序博客网 时间:2024/06/05 05:24
在需要模糊的UIView上,添加一个UIVisualEffectView对象即可。
效果如下图:
UIBlurEffectStyleExtraLight UIBlurEffectStyleLight UIBlurEffectStyleDark
代码如下(运行在iOS8版本前的模拟器上高斯模糊效果就没有了):
UIImageView *imageview = [[UIImageView alloc] init];
imageview.frame = CGRectMake(10, 100, 300, 300);
imageview.image = [UIImage imageNamed:@"2"];
imageview.contentMode = UIViewContentModeScaleAspectFit;
imageview.userInteractionEnabled = YES;
[self.view addSubview:imageview];
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectview = [[UIVisualEffectView alloc] initWithEffect:blur];
effectview.frame = CGRectMake(0, 0, imageview.size.width/2, 300);
[imageview addSubview:effectview];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(10, 50, 100, 40);
[btn setTitle:@"btn" forState:UIControlStateNormal];
[effectview.contentView addSubview:btn];
如果想在xib中直接放一个UIVisualEffectView,则工程的deployment target需要8.0以上,否则会报错编译不过。
但是在xib中放置UIToolbar并且通过代码设置相关属性以实现高斯模糊,工程的deployment target只要是5.0以上都可以编译通过,只不过在iOS7版本之前设备上没有高斯模糊效果。
- iOS高斯模糊实现
- IOS实现高斯模糊
- iOS实现图片高斯模糊效果
- iOS实现图片高斯模糊
- ios 高斯模糊
- 实现高斯模糊
- iOS 图片模糊效果(高斯模糊)
- iOS 视图高斯模糊(毛玻璃)效果实现
- iOS一种高斯模糊渐变动画的实现
- iOS 毛玻璃效果和高斯图片模糊实现
- iOS自带实现高斯模糊效果
- iOS 高斯模糊 效果
- iOS 图片高斯模糊
- iOS 高斯模糊效果
- 实现图片模糊,高斯模糊
- 高斯模糊实现小结
- 高斯模糊实现小结
- opencv实现高斯模糊
- 静态内部类
- StringBuffer类的使用方法----转自 凤舞天煌
- MySQL修改表的字段
- Hadoop之YARN命令
- C++中类型数据所占字节数
- iOS高斯模糊实现
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 百练 2809:计算2的N次方
- 使用quratz定时调用
- linux c语言 select函数用法
- iPhone屏幕尺寸、分辨率及适配
- 让MySQL支持Emoji表情
- 自定义Tomcat 404错误页面
- 带安卓系统的4G模块SLM751