iOS CALayer动画中使用的3个tree
在网上经常看到关于layer的tree的描述,不太理解,今天找到了官方文档,原文在Core Animation Programming Guide 中。
Layer Trees Reflect Different Aspects of the Animation State
An app using Core Animation has three sets of layer objects. Each set of layer objects has a different role in making the content of your app appear onscreen:
Objects in the model layer tree (or simply “layer tree”) are the ones your app interacts with the most. The objects in this tree are the model objects that store the target values for any animations. Whenever you change the property of a layer, you use one of these objects.
Objects in the presentation tree contain the in-flight(飞行中) values for any running animations. Whereas the layer tree objects contain the target values for an animation, the objects in the presentation tree reflect the current values as they appear onscreen. You should never modify the objects in this tree. Instead, you use these objects to read current animation values, perhaps to create a new animation starting at those values.
Objects in the render tree perform the actual animations and are private to Core Animation.
Each set of layer objects is organized into a hierarchical structure like the views in your app. In fact, for an app that enables layers for all of its views, the initial structure of each tree matches the structure of the view hierarchy exactly. However, an app can add additional layer objects—that is, layers not associated with a view—into the layer hierarchy as needed. You might do this in situations to optimize your app’s performance for content that does not require all the overhead of a view. Figure 1-9 shows the breakdown(分解) of layers found in a simple iOS app. The window in the example contains a content view, which itself contains a button view and two standalone layer objects. Each view has a corresponding layer object that forms part of the layer hierarchy.
Figure 1-9 Layers associated with a window
For every object in the layer tree, there is a matching object in the presentation and render trees, as shown in Figure 1-10. As was previously mentioned, apps primarily work with objects in the layer tree but may at times access objects in the presentation tree. Specifically, accessing the presentationLayer
property of an object in the layer tree returns the corresponding object in the presentation tree. You might want to access that object to read the current value of a property that is in the middle of an animation.
Figure 1-10 The layer trees for a window
Important: You should access objects in the presentation tree only while an animation is in flight. While an animation is in progress, the presentation tree contains the layer values as they appear onscreen at that instant. This behavior differs from the layer tree, which always reflects the last value set by your code and is equivalent to the final state of the animation.
简单总结一下,CALayer的动画实现过程中,为了实现layer的动画效果,使用了3个tree,其中layer tree就是存放目的值的;presentation tree在动画运动中,存放实时的值,可以通过presentationLayer来访问这个tree中的属性;render tree 是系统用来绘制动画的tree,不需要理会。
iOS CALayer动画中使用的3个tree的更多相关文章
- iOS学习笔记:iOS核心动画中的常用类型
CATransaction 当我们在自定义的图层上修改某些支持动画的属性时,系统会为该属性的修改自动产生动画.这种其实属于隐式动画.隐式动画要得益于CATransaction. 一个CATransac ...
- iOS 开发--动画
在iOS开发中,制作动画效果是最让开发者享受的环节之一.一个设计严谨.精细的动画效果能给用户耳目一新的效果,吸引他们的眼光 —— 这对于app而言是非常重要的.我们总是追求更为酷炫的实现,如果足够仔细 ...
- iOS开发之动画中的时间(概况)
一.引言 在iOS开发中使用动画时,可以通过设置动画的duration.speed.begintime.offset属性,来设置动画的时长.速度.起始时间及起始偏移. 用一个简单的例子来说明各个参数的 ...
- iOS核心动画高级技巧之CALayer(一)
iOS核心动画高级技巧之CALayer(一) iOS核心动画高级技巧之图层变换和专用图层(二)iOS核心动画高级技巧之核心动画(三)iOS核心动画高级技巧之性能(四)iOS核心动画高级技巧之动画总结( ...
- iOS开发之动画中的时间
概述 在动画中,我们会指定动画的持续时间.例如 scaleAnimation.duration = self.config.appearDuration 那么这个时间是怎么定义的呢?是指的绝对时间吗? ...
- iOS动画中的枚举UIViewAnimationOptions
若本帖转出“博客园”请注明出处(博客园·小八究):http://www.cnblogs.com/xiaobajiu/p/4084747.html 笔记 首先这个枚举属于UIViewAnimation. ...
- (转发)IOS动画中的枚举UIViewAnimationOptions
若本帖转自(博客园·小八究):http://www.cnblogs.com/xiaobajiu/p/4084747.html 可怜目前天朝搜不到什么有价值的东西方便学习,在这里方便初学者. 首先这个枚 ...
- iOS:项目中疑难Crash问题集锦
项目中疑难Crash问题集锦 iOS App运行中遇到Crash的情况相信大家都遇到过,开发和者测试中遇到了可能很方便的办法就是直接拿着设备连接一下,然后使用Xcode自带的工具就可以解析出Crash ...
- iOS核心动画学习整理
最近利用业余时间终于把iOS核心动画高级技巧(https://zsisme.gitbooks.io/ios-/content/chapter1/the-layer-tree.html)看完,对应其中一 ...
随机推荐
- Html-Css-iframe的自适应高度方案
先看一个示例,有两个页面,1.html通过iframe嵌入2.html,两个页面都是同域的 a.html <!DOCTYPE html> <html> <head> ...
- Java-小数点控制
package 运算及类型转换类; import java.text.DecimalFormat; public class 控制小数点类 { public static double decimal ...
- 【poj1080】 Human Gene Functions
http://poj.org/problem?id=1080 (题目链接) 题意 给出两个只包含字母ACGT的字符串s1.s2,可以在两个字符串中插入字符“-”,使得s1与s2的相似度最大. Solu ...
- Tomcat Can't load AMD 64-bit .dll on a IA 32
Java.lang.UnsatisfiedLinkError: C:\apache\apache-tomcat-7.0.14\bin\tcnative-1.dll: Can't load AMD 64 ...
- curl 命令行应用
我一向以为,curl只是一个编程用的函数库. 最近才发现,这个命令本身,就是一个无比有用的网站开发工具,请看我整理的它的用法. =================================== ...
- IbatisNet的介绍和使用
http://dragonsuc.cnblogs.com/archive/2006/07/04/ibatisnet.html IbatisNet的介绍和使用http://files.cnblogs.c ...
- 求三数中Max和猜拳游戏
方法一: Console.WriteLine("请输入三个数字:"); int a = int.Parse(Console.ReadLine()); int b = int.Par ...
- ci默认控制器
默认控制器 前面提到,如果在请求中没有指明具体的控制器,CI将会把页面重定向到一个系统默认的页面.这个默认页面可以自己设定,它存放在如下地址:/system/application/config/ro ...
- Java及Android开发环境搭建
前言 自从接触java以来,配置环境变量折腾了好几次,也几次被搞得晕头转向,后来常常是上网查阅相关资料才解决.但是过一段时间后一些细节就会记不清了,当要在其他机子上配置时又得上网查或者查阅相关书籍,如 ...
- hdu 1176 免费馅饼(动态规划)
AC code: #include<stdio.h> #include<string.h> #define max(a,b) (a>b?a:b) #define maxo ...