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: @.通过写故事来设计应用. @.每个故事只关注一件事. @.不同的故事可能使用相同的组件,因此尽早地 ...
随机推荐
- 谈谈final、finally和finalize
final: final为修饰符, 如果类被声明为final,则不能派生新子类. 如果变量被声明为final,则必须在声明时初始化,在以后的引用只能读取,不可修改. 如果方法被final声明,则只能使 ...
- STL"源码"剖析-重点知识总结
STL是C++重要的组件之一,大学时看过<STL源码剖析>这本书,这几天复习了一下,总结出以下LZ认为比较重要的知识点,内容有点略多 :) 1.STL概述 STL提供六大组件,彼此可以组合 ...
- AI线性图标教程-转起
- easyui不提交window中的form表单数据
<form id="ff" method="post">, <div id="win" class="easyu ...
- JavaWeb高性能开发(一)
今日要闻: 淘宝删差评产业链 在你给出"差评""中评"后不久,有人会偷偷登录你的淘宝账户,把你之前给过的评价删除或改成"好评".而这种人就是 ...
- Strider SSH Deploy配置
登录需要ssh, ssh 免密码登录配置自行百度.shell里写成自己的需要的命令
- Delphi Refactor 重构
delphi refactor procedure TCameraComponentForm.btnRefreshConfigClick(Sender: TObject); var a:string; ...
- Docker进入主流,PaaS大有可为(转)
add by zhj: 文章简单的说了PaaS所使用的传统容器的缺点,而docker这个容器在一定程度上解决了这些问题,越来越多的PaaS平台使用docker作容器,实现应用的隔离.不过,由于dock ...
- deque 居然已经实现了 insert 接口
最近有个开发需求,根据server传递来的广告位来展示某条广告. 但最终存储广告的数据结构是deque,里面存储的东西还是对象(stl 基于拷贝语义). 想了半天,在开头和结尾插入比较方便,在中间插入 ...
- 关于iTunes11.1 不能刷自制固件的解决方案
由于iTunes升级到11.1后, 苹果在程序里限制了不允许刷自制固件, 所以想刷自制固件暂时只能降级iTunes到11.1版本之前, 这里提供iTunes 11.0.5 的下载地址: Windows ...