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 ...
随机推荐
- [APIO2018] Circle selection 选圆圈
Description 给出 \(n\) 个圆 \((x_i,y_i,r_i)\) 每次重复以下步骤: 找出半径最大的圆,并删除与这个圆相交的圆 求出每一个圆是被哪个圆删除的 Solution \(k ...
- js验证身份证号码是否合规
需求:最近要做实名验证的功能,但是验证身份证号码和身份证图片的接口不想短信,比较贵,所以之前我们要验证严谨一点,参考了网上关于验证身份证号码的代码,总结一下 代码: //验证身份证号码 functio ...
- [转]How can I install the VS2017 version of msbuild on a build server without installing the IDE?
本文转自:http://stackoverflow.com/questions/42696948/how-can-i-install-the-vs2017-version-of-msbuild-on- ...
- TCP学习(一)
协议分层 可以看到 物理层, 链路层,网络层是所有网络设备共有的, 而传输层, 会话层, 表示层, 应用层 是存在于主机上的 各设备实现的协议层次 IP地址的表示 为什么会出现ip地址?是为了在一 ...
- 用c+libcurl+PCRE写爬虫2--好用的正则表达式
写爬虫最重要的就是正则表达式的处理(爬出来的数据的筛选,清洗,过滤等操作). 通过一篇文章 http://blog.csdn.net/quaful/article/details/6460880 来确 ...
- java.util.concurrent.Semaphore 使用
1. 概述 Semaphore(信号) 并不存在真正的许可 只是维护一个计数器, 通常用来限定进入一些资源的线程数 accquire() 方法获取许可 成功则计数器值-1 没有则阻塞直到一个可用的 ...
- webpack_hmr报错 cannot load 状态500
使用vue-cli时,启动本地环境,然后页面没有关闭,直接切换到线上环境,过一会会发起一个http://xxx/__webpack_hmr请求,会报cannot load原因:它属于nodejs中的一 ...
- MySQL数据库(1)----入门级操作
1.在服务器主机上以 root 用户登陆,创建位于其他客户端的新用户: mysql> CREATE USER 'newuser'@'192.168.1.109' IDENTIFIED BY 'p ...
- Apache服务器运维笔记(3)----容器部分
1.<IfModule>容器 <IfModule>容器作用于模块,它会首先判断模块是否载入,然后再决定是否进行处理,也就是说只有当判断结果为真时才会执行容器内的指令,相反如果为 ...
- CentOS 7运维管理笔记(3)----Linux路由器配置
当正在配置的Linux主机需要作为路由器使用时,通过以下步骤配置后,子网上的计算机就可以访问外网了: 1. 编辑 /etc/sysctl.conf 文件,添加 net.ipv4_ip_forward ...