CALayer & bitmap Content
Working with High-Resolution Images
Layers do not have any inherent knowledge of the resolution of the underlying device’s screen. A layer simply stores a pointer to your bitmap and displays it in the best way possible given the available pixels. If you assign an image to a layer’s contents property, you must tell Core Animation about the image’s resolution by setting the layer’s contentsScale property to an appropriate value.
Providing a Layer’s Contents
Layers are data objects that manage content provided by your app. A layer’s content consists of a bitmap containing the visual data you want to display. You can provide the content for that bitmap in one of three ways:
- Assign an image object directly to the layer object’s contents property. (This technique is best for layer content that never, or rarely, changes.)
- Assign a delegate object to the layer and let the delegate draw the layer’s content. (This technique is best for layer content that might change periodically and can be provided by an external object, such as a view.)
- Define a layer subclass and override one of its drawing methods to provide the layer contents yourself. (This technique is appropriate if you have to create a custom layer subclass anyway or if you want to change the fundamental drawing behavior of the layer.)
The only time you need to worry about providing content for a layer is when you create the layer object yourself. If your app contains nothing but layer-backed views, you do not have to worry about using any of the preceding techniques to provide layer content. Layer-backed views automatically provide the contents for their associated layers in the most efficient way possible.
Using an Image for the Layer’s Content
Because a layer is just a container for managing a bitmap image, you can assign an image directly to the layer’s contents property. Assigning an image to the layer is easy and lets you specify the exact image you want to display onscreen. The layer uses the image object you provide directly and does not attempt to create its own copy of that image. This behavior can save memory in cases where your app uses the same image in multiple places.
The image you assign to a layer must be a CGImageRef type.
CALayer & bitmap Content的更多相关文章
- CALayer总结(二)
1.CATransaction 事务: UIView有两个方法,+beginAnimations:context:和+commitAnimations,和CATransaction的+begin 和+ ...
- [iOS Animation]-CALayer 显示动画
显式动画 如果想让事情变得顺利,只有靠自己 -- 夏尔·纪尧姆 上一章介绍了隐式动画的概念.隐式动画是在iOS平台创建动态用户界面的一种直接方式,也是UIKit动画机制的基础,不过它并不能涵盖所有的动 ...
- 关于CALayer 中的contents(图片) 拉伸
最近做有关 发送图片的功能.微信显示的图片 使用气泡遮罩出来的..而且图片尺寸也不止一种. 既然UIImagView 可以拉伸图片,设置遮罩的CALayer 的content 可不可以. 关键CALa ...
- 理解UIView的绘制-孙亚洲
前言 最近研究OpenGL ES相关和 GPU 相关 发现这篇文章很具有参考的入门价值. 理解 UIView 的绘制, UIView 是如何显示到 Screen 上的? 首先要从Runloop开始说, ...
- UIView 绘制渲染机制
#前言 APP页面优化对小编来说一直是难题,最近一直在不断的学习和总结 ,发现APP页面优化说到底离不开view的绘制和渲染机制.网上有很多精彩的博客,小编借鉴之前N多大牛研究成果,同时结合自己遇到的 ...
- [AS3]as3画笔实例实现橡皮擦功能源代码
[AS3]as3画笔实例实现橡皮擦功能源代码 //主容器 var main:Sprite = new Sprite(); main.mouseEnabled = false; addChild(mai ...
- android常见问题(一)
一:文本的颜色选择器: 在res目录下面创建color文件夹,在color文件夹下面创建font_style_colors.xml文件<?xml version="1.0" ...
- CATransition(过渡)
属性动画只对图层的可动画属性起作用,所以如果要改变一个不能动画的属性(比如图片),或者从层级关系中添加或者移除图层,属性动画将不起作用. 于是就有了过渡的概念.过渡并不像属性动画那样平滑地在两个值之间 ...
- [ActionScript 3.0] AS3.0 把图片分析成文本表现形式
PLP%uffs??1ti4b5I3iI5CMMGGE8Ta8?c8[mm3CF9sLaXZDll6kpjmhGmhE$GONEENhhGl6OWXb9lkNk0kkNpklZW6&bDN0q ...
随机推荐
- mysql 8 root密码重置
亲测有效. https://blog.csdn.net/gupao123456/article/details/80766154
- RUP 4+1视图
RUP开篇之作:http://www.ibm.com/developerworks/cn/rational/r-4p1-view/index.html 百科:http://baike.baidu.co ...
- SQL执行一次INSERT INTO查询,插入多行记录
那如果我们想插入多行记录呢?可能你会想到多次运行INSERT语句即可,就像下面的php代码示例: INSERT INTO tbl_name (col1,col2) VALUES (,); 那如果我们想 ...
- ajax上传数据
---恢复内容开始--- ajax上传数据,(简洁版) 1.上传普通同表单标签内容. 1.获取表单的内容 1. var file=$('#file').val();(放在点击事件后面) 2. var ...
- JBPM学习第3篇:10分钟熟悉JBPM工作台
1.打开:http://localhost:8080/jbpm-console 键入用户名和密码(krisv/krisv)登陆. 2.看视频: http://download.jboss.org/jb ...
- c# json数组动态字段名
根据给定的列名动态生成json数组 List<string> cols = new List<string>() { "姓名","性别" ...
- ios的白屏坑
请参考http://www.fly63.com/article/detial/287
- Codeforces Round #412 A Is it rated ?
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes Is it rated? Her ...
- 字符数字转换 atoi 与 strtol
原文:http://www.cnblogs.com/JefferyZhou/archive/2010/07/01/1769555.html 在很多时候我们都很清楚 atoX 系列函数: atoi , ...
- IsWindow,findwindow
原文:http://www.cnblogs.com/ahuo/archive/2007/12/05/983354.html IsWindow 函数功能:该函数确定给定的窗口句柄是否识别一个已存在的窗口 ...