Core Animation学习笔记—第一节Core Animation Basics

各位iOS开发大佬们好:
我是一名swift+swiftUI栈的iOS小白,目前还在上大三,最近准备实习,面试的过程中发现现在大公司很多还在用OC + UIKit的技术栈,OC我还在考虑要不要学,目前想先把UIKit学完,这是我在官网学习UIKit英文文档时摘录的本人认为的重点,如果你们也觉得对你们有用的话欢迎持续关注,我大概一天更一节,有事除外。格式什么的我也就不做了,翻译都是我自己翻译的,哪里不对欢迎在评论区指正,感谢各位大佬支持

今天2021年12月1日
这一章叫做Core Animation Basics

以下为可视化内容的渲染和封装关系
在这里插入图片描述

It achieves this behavior by caching the contents of views into bitmaps that can be manipulated directly by the graphics hardware
它通过将视图的内容缓存到可由图形硬件直接操作的位图中来实现此行为

In addition to caching view content, Core Animation also defines a way to specify arbitrary visual content, integrate that content with your views, and animate it along with everything else.
除了缓存视图内容外,Core Animation还定义了一种方法来指定任意视觉内容,即:将该内容与您的视图集成,并将其与其他所有内容一起动画化。

在这里插入图片描述

当某个属性变化触发动画时,Core Animation向图形硬件传递layer的位图和状态信息,图形硬件使用新值渲染位图

Layer使用两种坐标系统,一个是点坐标系统,一个是单位坐标系统,点坐标系统适用于像position这类可以直接将layer映射到具体位置的,单位坐标系统一般用于与其他属性相关联的,比如anchorPoint这类和bounds有关的属性,两套坐标系统均使用浮点数定位

下来就是老生常谈,iOS下坐标原点在左上,os x下坐标系统在左下

在这里插入图片描述
在这里插入图片描述

Geometry related manipulations of a layer occur relative to that layer’s anchor point, which you can access using the layer’s anchorPoint property. The impact of the anchor point is most noticeable when manipulating the position or transform properties of the layer. The position property is always specified relative to the layer’s anchor point, and any transformations you apply to the layer occur relative to the anchor point as well.
anchorPoint影响着position和transform属性,

在这里插入图片描述
在这里插入图片描述

layer的transform属性改变时会影响子layer,sublayerTransform只会影响子layer

Transforms work by multiplying coordinate values through a matrix of numbers to get new coordinates that represent the transformed versions of the original points. Because Core Animation values can be specified in three dimensions, each coordinate point has four values that must be multiplied through a four-by-four matrix, as shown in Figure 1-7. In Core Animation, the transform in the figure is represented by the CATransform3D type. Fortunately, you do not have to modify the fields of this structure directly to perform standard transformations. Core Animation provides a comprehensive set of functions for creating scale, translation, and rotation matrices and for doing matrix comparisons. In addition to manipulating transforms using functions, Core Animation extends key-value coding support to allow you to modify a transform using key paths.
转换的工作原理是通过数字矩阵乘以坐标值,以获得代表原始点转换版本的新坐标。由于Core Animation值可以在三维中指定,因此每个坐标点有四个值,必须通过4*4矩阵,如图1-7所示。在Core Animation中,图中的变换由CATransform3D类型表示。不需要直接修改此结构的字段来执行标准转换。Core Animation为创建比例、翻译和旋转矩阵以及进行矩阵比较提供了一整套功能。除了使用函数操作转换外,Core Animation还扩展了键值编码支持,允许您使用键路径修改转换。

在这里插入图片描述
在这里插入图片描述

转换对应的矩阵形式

三个layer对象集
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.
Model集,储存了为动画所使用的属性更改的目标值,
Presentation集,使用属性当前时刻的值来显示layer当前状态
渲染集,渲染实际的动画
presentationLayer 属性获取当前layer在presentation集中的对象
Presentation对象应该在动画结束后获取,因为presentation对象呈现的是实时的值,而layer集仅呈现动画完成时的值
在这里插入图片描述
在这里插入图片描述

Guess you like

Origin blog.csdn.net/Programmer_Roy/article/details/121642253