iOS8模糊效果UIVisualEffectView的使用

效果:

源码:

//
// ViewController.m
// EffectView
//
// Created by XianMingYou on 15/3/14.
// Copyright (c) 2015年 XianMingYou. All rights reserved.
// #import "ViewController.h" @interface ViewController ()
@property (nonatomic, strong) UIVisualEffectView *effectView;
@property (nonatomic, strong) UIVisualEffectView *vibrancyEffectView;
@property (nonatomic, strong) UIScrollView *scrollView;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; // 添加测试用view
[self.view addSubview:self.scrollView]; // 添加模糊用view
[self.view addSubview:self.effectView]; // 添加额外的view(用contentView)
[self.effectView.contentView addSubview:self.vibrancyEffectView];
} @synthesize scrollView = _scrollView;
- (UIScrollView *)scrollView {
if (_scrollView == nil) {
_scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.bounces = NO;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"color.jpg"]];
_scrollView.contentSize = imageView.image.size;
[_scrollView addSubview:imageView];
} return _scrollView;
} @synthesize effectView = _effectView;
- (UIVisualEffectView *)effectView {
if (_effectView == nil) {
// 添加模糊效果
_effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
_effectView.userInteractionEnabled = NO;
_effectView.frame = CGRectMake(, , , );
_effectView.center = self.view.center;
} return _effectView;
} @synthesize vibrancyEffectView = _vibrancyEffectView;
- (UIVisualEffectView *)vibrancyEffectView {
if (_vibrancyEffectView == nil) {
// 初始化文本
UILabel *label = [[UILabel alloc] initWithFrame:self.effectView.bounds];
label.text = @"YouXianMing";
label.font = [UIFont systemFontOfSize:.f];
label.textAlignment = NSTextAlignmentCenter; // 需要与作用的effectView的效果一致
_vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIVibrancyEffect effectForBlurEffect:(UIBlurEffect *)self.effectView.effect]];
_vibrancyEffectView.frame = self.effectView.bounds; // 注意,是用的contentView添加label
[self.vibrancyEffectView.contentView addSubview:label];
} return _vibrancyEffectView;
} @end

测试用图片:

iOS8模糊效果UIVisualEffectView的使用的更多相关文章

  1. iOS8中用UIVisualEffectView实现高斯模糊视图(毛玻璃效果)

    UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; UIVisualEffectView *vi ...

  2. iOS开发之功能模块--模糊效果

    1.先介绍一个好用的实现模糊效果的框架:https://github.com/YouXianMing/UIImageBlur 2.iOS8 中 UIVisualEffectView 模糊效果的使用 , ...

  3. CoreImage 中的模糊滤镜

    1.CoreImage 中的模糊滤镜 1.1CoreImage是苹果用来简化图片处理的框架 1.2CIImage.CIFilter与CIContext三者联系 1.3CIGaussianBlur中可能 ...

  4. UIVisualEffectView(高斯模糊效果)

    ///高斯模糊. UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; tempView. ...

  5. IOS8模糊毛玻璃的效果UIVisualEffectView

    UIVisualEffectView实现两种模糊效果:UIBlurEffect 和 UIVibrancyEffect 两者都是继承自UIView,前者放在任意的View里边都能对下册的视图渲染出模糊效 ...

  6. Swift 之模糊效果(毛玻璃效果,虚化效果)的实现

    前言: 之前项目中有用到过Objective-C的的模糊效果,感觉很是不错,而且iOS8之后官方SDK也直接提供了可以实现毛玻璃效果的三个类:UIBlurEffect.UIVibrancyEffect ...

  7. iOS模糊效果(毛玻璃效果)的实现

    前一段时间项目中用到毛玻璃效果,那时对UIBlurEffect类和 UIVisualEffectView这两个类做了一部分了解.但当时并没有去特别的深入研究,直到项目做完后,才静下心来好好研究了一番. ...

  8. [Xcode 实际操作]六、媒体与动画-(6)使用UIBlurEffect给图片添加模糊效果

    目录:[Swift]Xcode实际操作 本文将演示如何给图像添加模糊效果. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit class V ...

  9. iOS 开发之模糊效果的五种实现

    前言 在iOS开发中我们经常会用到模糊效果使我们的界面更加美观,而iOS本身也提供了几种达到模糊效果的API,如:Core Image,使用Accelerate.Framework中的vImage A ...

随机推荐

  1. 【文档】三、Mysql Binlog事件类文件和类型

    在内部,服务器使用C++类文件来表示binlog事件.标准在log_event.h文件中,这些类的方法代码在log_event.cc中. log_event是基础类.其他的详细的事件子类都是来源于他. ...

  2. jenkins构建GitHub项目

    一.Jenkins 配置 Git 首先,登录 Jenkins ,在首页找到 “系统管理 -> Global Tool Configuration -> Git ” Path to Git ...

  3. [问题解决]Fresco设置圆角效果不生效问题探究

    [问题解决]Fresco设置圆角效果不生效问题探究 /** * Created by diql on 2017/2/21 11:07:04. */ 问题 在View中设置: fresco:rounde ...

  4. java.lang.IllegalStateException: Unknown Priority XXXX 的解决方法

    异常信息: java.lang.IllegalStateException: Unknown Priority SYS_ERR_SMS at org.apache.log4j.Category.pri ...

  5. c++ 网络编程课设入门超详细教程 ---目录

    原文作者:aircraft 原文链接:https://www.cnblogs.com/DOMLX/p/9663167.html c++ 网络编程(一)TCP/UDP windows/linux 下入门 ...

  6. python-tornado-hello,world

    #!/usr/bin/python import tornado.httpserver import tornado.ioloop import tornado.options import torn ...

  7. Struts dispatchAction

    在Struts中定义动态Action,不用定义多个Action,可以实现一个action,多个跳转. 在定义时,继承DispatchAction,并定义parameter的名字 在jsp页面选择act ...

  8. 更改SQLServer实例默认字符集

    转自http://www.cnblogs.com/fygh/archive/2012/05/15/2501598.html 需求 安装数据库时,将字符集安装成了“SQL_Latin1_General_ ...

  9. android_serialport_api代码分析

    1. 导入Android studio android_serialport_api是一个开源的串口测试工具,代码应该是用eclipse工程(不确定,没用过eclipse,反正不是Android st ...

  10. mvc手把手教你写excel导入[mvc+三层,没用EF]

    实习狗的每天新知识日常 准备工作: 1.在项目中添加对NPOI的引用,NPOI下载地址:http://npoi.codeplex.com/releases/view/38113 2.NPOI学习系列教 ...