• Layer Trees Reflect Different Aspects of the Animation State


    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreAnimation_guide/CoreAnimationBasics/CoreAnimationBasics.html#//apple_ref/doc/uid/TP40004514-CH2-SW3

    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 presentationLayerproperty 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.

  • 相关阅读:
    luogu CF804D Expected diameter of a tree |Tarjan+樹的直徑+前綴和+二分查找
    luogu CF25C Roads in Berland |最短路floyd
    自觉日志·1·再现曾经的自觉
    祝福您新年快乐!
    自觉体验十一 体验祝福,与弘誓大愿!
    自觉体验 十 体验失忆
    自觉体验 六 手语与结印
    自觉体验 一  闲来无事,闭目养神
    我将离开屏幕前的“      ”
    第五章  自觉与【转载】《大念处经》
  • 原文地址:https://www.cnblogs.com/feng9exe/p/6733656.html
Copyright © 2020-2023  润新知