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 ...
随机推荐
- 【转发】Webdriver使用自定义Firefox Profile运行测试
点击进入转发地址: 一般我们使用如下代码启动Firefox: 这样Selenium Server启动的Firefox将是一个全新的,不安装任何Add-On的Firefox. 如果有需要,我们可以使用我 ...
- TestNG学习地址分享
谨以此随笔来记录一个曾经学习TestNG的网站,供以后作为工具书查阅. 链接地址,点击此处.
- thumbnailator + webp-imageio-core实现java处理图片支持webp
thumbnailator提供了便捷的图片处理api,webp-imageio-core屏蔽了不同平台webp本地库的差异. <dependency> <groupId>com ...
- Java 中 String 的构造方法
String 对于所有 Java 程序员来说都不会陌生,几乎每天甚至每个程序都会和 String 打交道,因此将 String 的常用知识汇集在此,方便查阅. 概叙: Java 中是如此定义 Stri ...
- *2.2.4 加入virtual interface
在前几节的例子中,driver中等待时钟事件(@posedge top.clk).给DUT中输入端口赋值(top.rx_dv <= 1' b1)都是使用绝对路径,绝对路径的使用大大减弱了验证平台 ...
- Python DataFrame导出CSV、数据库
写入Oracle from sqlalchemy import create_engine import pandas as pd import numpy as np df = pd.DataFra ...
- [Mysql 查询语句]——对查询结果进一步的操作
distinct 不显示重复的查询结果 (1) 对于表中一些没有唯一性约束的字段,可能存在重复的值,这时可以使用distinct来消除那些查询结果中的重复值 select cust_id from ...
- CentOS和RedHat等系列系统 yum源配置、时间同步
一.yum源配置 1,进入yum源配置目录cd /etc/yum.repos.d 2,备份系统自带的yum源mv CentOS-Base.repo CentOS-Base.repo.bk下载163网易 ...
- 微信小程序 c#后台支付结果回调
又为大家带来简单的c#后台支付结果回调方法,首先还是要去微信官网下载模板(WxPayAPI),将模板(WxPayAPI)添加到服务器上,然后在打开WxPayAPI项目中的example文件下的 Nat ...
- as3中xml文件的加载和读取
---恢复内容开始--- as代码如下: xml如下: 总结: 用URLReuqest对象加载xml的url 创建一个URLLoader对象,将1中的URLRequest指定给他 给URLLoader ...