iOS 7 Pushing the Limits Notes - create a layer like notification center's or control center's background
Problem:
How to create a layer that looks like your notification center's or control center's background
Solution:
Using UIImage+ImageEffects to Create a Blurred Popup Layer
Code Fragments:
// create the layer
self.layer = [CALayer layer];
self.layer.frame = CGRectMake(, , , );
[self.view.layer addSublayer:self.layer];
// Take the screenshot
float scale = [UIScreen mainScreen].scale;
UIGraphicsBeginImageContextWithOptions(self.view.frame.size, YES, scale);
[self.view drawViewHierarchyInRect:self.view.frame afterScreenUpdates:NO];
__block UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Crop the screenshot
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage,
CGRectMake(self.layer.frame.origin.x * scale,
self.layer.frame.origin.y * scale,
self.layer.frame.size.width * scale,
self.layer.frame.size.height * scale));
image = [UIImage imageWithCGImage:imageRef];
// Apply the effect
image = [image applyBlurWithRadius:50.0f
tintColor:
[UIColor colorWithRed: green: blue: alpha:0.1]
saturationDeltaFactor:
maskImage:nil];
// assign it to the new layer's contents
self.layer.contents = (__bridge id)(image.CGImage);
iOS 7 Pushing the Limits Notes - create a layer like notification center's or control center's background的更多相关文章
- iOS 7 Pushing the Limits - Good & Bad Namings in Cocoa
Cocoa is a dynamically typed language, and you can easily get confused about what type you are worki ...
- [iOS翻译]《iOS 7 Programming Pushing the Limits》系列:你可能不知道的Objective-C技巧
简介: 如果你阅读这本书,你可能已经牢牢掌握iOS开发的基础,但这里有一些小特点和实践是许多开发者并不熟悉的,甚至有数年经验的开发者也是.在这一章里,你会学到一些很重要的开发技巧,但这仍远远不够,你还 ...
- Android Programming: Pushing the Limits -- Chapter 7:Android IPC -- Messenger
Messenger类实际是对Aidl方式的一层封装.本文只是对如何在Service中使用Messenger类实现与客户端的通信进行讲解,对Messenger的底层不做说明.阅读Android Prog ...
- Android Programming: Pushing the Limits -- Chapter 7:Android IPC -- ApiWrapper
前面两片文章讲解了通过AIDL和Messenger两种方式实现Android IPC.而本文所讲的并不是第三种IPC方式,而是对前面两种方式进行封装,这样我们就不用直接把Aidl文件,java文件拷贝 ...
- iOS开发CoreAnimation解读之三——几种常用Layer的使用解析
iOS开发CoreAnimation解读之三——几种常用Layer的使用解析 一.CAEmitterLayer 二.CAGradientLayer 三.CAReplicatorLayer 四.CASh ...
- Android Programming: Pushing the Limits -- Chapter 7:Android IPC -- AIDL
服务端: 最终项目结构: 这个项目中,我们将用到自定义类CustomData作为服务端与客户端传递的数据. Step 1:创建CustomData类 package com.ldb.android.e ...
- Android Programming: Pushing the Limits -- Chapter 6: Services and Background Tasks
什么时候使用Service 服务类型 开启服务 后台运行 服务通信 附加资源 什么时候使用Service: @.任何与用户界面无关的操作,可移到后台线程,然后由一个Service来控制这个线程. 服务 ...
- Android Programming: Pushing the Limits -- Chapter 5: Android User Interface Operations
多屏幕 自定义View 多屏幕 @.Android 4.2 开始支持多屏幕. @.举例: public class SecondDisplayDemo extends Activity { priva ...
- Android Programming: Pushing the Limits -- Chapter 4: Android User Experience and Interface Design
User Stories Android UI Design 附加资源 User Stories: @.通过写故事来设计应用. @.每个故事只关注一件事. @.不同的故事可能使用相同的组件,因此尽早地 ...
随机推荐
- -Xbootclasspath参数、java -jar参数运行应用时classpath的设置方法
当用java -jar yourJarExe.jar来运行一个经过打包的应用程序的时候,你会发现如何设置-classpath参数应用程序都找不到相应的第三方类,报ClassNotFound错误.实际上 ...
- Drupal 7.23:函数module_invoke_all()注释
/** * Invokes a hook in all enabled modules that implement it. * * All arguments are passed by value ...
- JS判断是不是本页面并且,给标签添加属性和属性值
大多是在导航栏中用到的,在导航栏中在主页和在其他的网页点击导航栏中的主页是不同的,主要就是判断这个. 我是在ascs页面中写的. 下面先看标签: <a href="http://www ...
- 程序世界系列之-struts2安全漏洞引发的安全杂谈(上)
目录: 1.讨论关于struts 安全问题. 2.黑客文化. 3.如何降低安全漏洞的出现. 4.忠告建议. 题记: 这篇文章本来很早应该和大家见面的,中间由于个人原因调整了系列文章发布时间,实属罪过. ...
- Autodesk Stingray 游戏引擎
Autodesk的游戏引擎质量够高的. http://v.youku.com/v_show/id_XMTMwMjc0MDIwMA==.html?qq-pf-to=pcqq.group http://v ...
- 凸包稳定性判断:每条边上是否至少有三点 POJ 1228
//凸包稳定性判断:每条边上是否至少有三点 // POJ 1228 #include <iostream> #include <cstdio> #include <cst ...
- log4net--帮助程序员将日志信息输出到各种目标(控制台、文件、数据库等)的工具
1. log4net库是Apache log4j框架在Microsoft .NET平台的实现,是一个帮助程序员将日志信息输出到各种目标(控制台.文件.数据库等)的工具. 2. Log4net的结构如下 ...
- Strom学习笔记一
---恢复内容开始--- Storm 是个实时的.分布式以及具备高容错的计算系统.同Hadoop一样Storm也可以处理大批量的数据,然而Storm在保证高可靠性的前提下还可以让处理进行的更加实时:也 ...
- SQL Server数学函数
数学函数 1.计算绝对值ABS ABS函数对一个数值表达式结果计算绝对值(bit数据类型除外),返回整数. 语法结构: ABS(数值表达式) 返回值:与数值表达式类型一致的数据 示例: ) --输出 ...
- C++11角括号
[C++11角括号] 标准 C++ 的剖析器一律将 ">>" 视为右移运算符. 但在样板定义式中,绝大多数的场合其实都代表两个连续右角括号. 为了避免剖析器误判,撰码时 ...