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 ...
随机推荐
- vs2010 编译 boost1.65.1
vs2010编译boos1.65.1注意选项 vs2010 不支持 c99 ,string.c和debugger.c 变量定义顺序位置报错,改变顺序即可. debugger.c va_copy 在c8 ...
- Compile android source and kernel for emulator in Debian
1.download the android source code Reference from http://source.android.com/source/downloading.html ...
- solr集群的搭建教程和使用入门
1 什么是SolrCloud? SolrCloud(solr 云)是Solr提供的分布式搜索方案,当你需要大规模,容错,分布式索引和检索能力时使用 SolrCloud. 当一个系统的索引数据量少的时候 ...
- WPF中C#代码触发鼠标点击事件
1.如下代码; <Button x:Name="btnTest" Click="btnTest_Click"> <Button.Trigger ...
- java1.8中ConcurrentHashMap
java1.8中的ConcurrentHashMap做了非常大的改动,整个数据结构都发生了变化,已经不存在segment了.所以要好好重新查看下源码.这篇博客是逐步更行的,看一点写一点. 首先看一个很 ...
- 详解shuffle过程(转载)
http://langyu.iteye.com/blog/992916 shuffle本意是洗牌的意思.在mapreduce中描述的是怎么将map task 的输出结果有效的传送到reduce tas ...
- jQuery插件开发之boxScroll与marquee
BoxScroll 常见图片轮播效果的简单实现.可以数字列表控制或者左右按键控制.逻辑很简单,下面的Marquee形成环,这个到了尽头得往回跑,看看注释就知道了. 图片轮播GitHub:https:/ ...
- 问题集录--Android:解决Studio新建项目时,在 Building gradle project info 一直卡住
Android Studio导入项目的时候,一直卡在Building gradle project info这一步,主要原因还是因为被墙的结果.gradle官网虽然可以访问,但是速度连蜗牛都赶不上.. ...
- [转]C#中Timer使用及解决重入问题
本文转自:http://www.cnblogs.com/hdkn235/archive/2014/12/27/4187925.html ★前言 打开久违的Live Writer,又已经好久没写博客了, ...
- 在ASP.NET中过滤HTML字符串总结
先记下来,以作备用! /// <summary>去除HTML标记 /// /// </summary> /// <param name="Htmls ...