iOS8模糊效果UIVisualEffectView的使用
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的使用的更多相关文章
- iOS8中用UIVisualEffectView实现高斯模糊视图(毛玻璃效果)
UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; UIVisualEffectView *vi ...
- iOS开发之功能模块--模糊效果
1.先介绍一个好用的实现模糊效果的框架:https://github.com/YouXianMing/UIImageBlur 2.iOS8 中 UIVisualEffectView 模糊效果的使用 , ...
- CoreImage 中的模糊滤镜
1.CoreImage 中的模糊滤镜 1.1CoreImage是苹果用来简化图片处理的框架 1.2CIImage.CIFilter与CIContext三者联系 1.3CIGaussianBlur中可能 ...
- UIVisualEffectView(高斯模糊效果)
///高斯模糊. UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; tempView. ...
- IOS8模糊毛玻璃的效果UIVisualEffectView
UIVisualEffectView实现两种模糊效果:UIBlurEffect 和 UIVibrancyEffect 两者都是继承自UIView,前者放在任意的View里边都能对下册的视图渲染出模糊效 ...
- Swift 之模糊效果(毛玻璃效果,虚化效果)的实现
前言: 之前项目中有用到过Objective-C的的模糊效果,感觉很是不错,而且iOS8之后官方SDK也直接提供了可以实现毛玻璃效果的三个类:UIBlurEffect.UIVibrancyEffect ...
- iOS模糊效果(毛玻璃效果)的实现
前一段时间项目中用到毛玻璃效果,那时对UIBlurEffect类和 UIVisualEffectView这两个类做了一部分了解.但当时并没有去特别的深入研究,直到项目做完后,才静下心来好好研究了一番. ...
- [Xcode 实际操作]六、媒体与动画-(6)使用UIBlurEffect给图片添加模糊效果
目录:[Swift]Xcode实际操作 本文将演示如何给图像添加模糊效果. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit class V ...
- iOS 开发之模糊效果的五种实现
前言 在iOS开发中我们经常会用到模糊效果使我们的界面更加美观,而iOS本身也提供了几种达到模糊效果的API,如:Core Image,使用Accelerate.Framework中的vImage A ...
随机推荐
- mysql 导入 csv 格式数据
mysql --local-infile -uroot -proot task_ops -e "LOAD DATA LOCAL INFILE '/tmp/data_import/app8.c ...
- win7下安装centos6.5后,开机无法进入选择双系统启动界面,只能启动centos的解决办法
1.centos6.5下打开终端,进入/boot/grub ,vim grub.conf 将default=0 改为1,重启 2.重启后,又只能进入win7了.这个好解决.下载一个easyBCD,具体 ...
- cnblog博客停用
本博客从今日起停止更新,后续的文章将会发布在新的博客mrbackkom.github.io
- PhpStorm 破解及 XDebug 调试
PhpStorm 破解及 XDebug 调试 PhpStorm 破解 PhpStorm 10.0.2 破解 地址:http://jingyan.baidu.com/article/20095761cb ...
- 二:Bootstrap-css组件
Glyphicons 图标: span.glyphicon glyphicon-align-center 下拉菜单: div.dropdown/div.btn-group button[data-to ...
- java使用lock实现一个简单的死锁程序
import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; public ...
- [LeetCode]Swap Nodes in Pairs题解
Swap Nodes in Pairs: Given a linked list, swap every two adjacent nodes and return its head. For exa ...
- json的省市联动
1 <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2 < ...
- UNIX 网络编程笔记-CH3:套接字编程简介
IPv4套接字地址结构 struct in_addr { in_addr_t s_addr; }; struct sockaddr_in { uint8_t sin_len; /* length of ...
- SQL修改表结构
--(1)向数据库Student表中添加Name字段 use MR_NXT alter table student add Name char(20) --(2)将Student表中Name的字段的数 ...