• CATransaction:原子化操作、批量操作、整体设置、自动添加


     Transactions are CoreAnimation's mechanism for batching multiple layer-

     tree operations into atomic updates to the render tree. Every

     modification to the layer tree requires a transaction to be part of.

    A CATransaction is always created every time you have a Core animation going on.

    Every modification to a layer is part of a transaction. CATransaction is the Core Animation class responsible for batching multiple layer-tree modifications into atomic updates to the render tree.

    https://www.cnblogs.com/feng9exe/p/6731081.html

    任何Layer的animatable属性的设置都应该属于某个CA事务(CATransaction),事务的作用是为了保证多个animatable属性的变化同时进行,不管是同一个layer还是不同的layer之间的.CATransaction也分两类,显式的和隐式的,当在某次RunLoop中设置一个animatable属性的时候,如果发现当前没有事务,则会自动创建一个CA事务,在线程的下个RunLoop开始时自动commit这个事务,如果在没有RunLoop的地方设置layer的animatable属性,则必须使用显式的事务.

    显式事务的使用如下:

    [CATransaction begin];

    ...  

    [CATransaction commit];

    事务可以嵌套.当事务嵌套时候,只有当最外层的事务commit了之后,整个动画才开始.

    可以通过CATransaction来设置一个事务级别的动画属性,覆盖隐式动画的相关属性,比如覆盖隐式动画的duration,timingFunction.如果是显式动画没有设置duration或者timingFunction,那么CA事务设置的这些参数也会对这个显式动画起作用.

    http://www.cnblogs.com/bucengyongyou/archive/2012/12/20/2826619.html

    CATransaction 在 Core Animation framework中主要扮演了“整体舞台设定的角色”。

    使用 CATransaction 的方式就是把我们想做的特别的设定的动画代码,用 CATransaction 的class method前后包起来。

    比方说,我们现在不希望产生动画,便可以这样写:

    [CATransaction begin];

    [CATransaction setDisableActions:YES];

    //原本动画的代码

    [CATransaction commit];

    如果我们想要改变动画时间:

    [CATransaction begin];

    [CATransaction setAnimationDuration:1.0];

    --------------------- 

    作者:学习笔记666 

    来源:CSDN 

    原文:https://blog.csdn.net/github_26672553/article/details/50608034 

    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    VCSA 6.5 升级 VCSA 6.7
    使用再生龙Clonezilla备份还原Linux系统
    gulp前端自动化构建工具学习笔记(mac)
    Echarts基本图表的学习笔记
    jQuery中$.ajax()用法
    jQuery实现淡入淡出轮播图带左右按钮及下方小圆点
    js解析XMl文件,兼容IE、Firefox、谷歌
    HTML<marquee>标签实现滚动公告通知、广告的效果
    画太极
    让IE6 IE7 IE8 IE9 IE10 IE11支持Bootstrap的解决方法
  • 原文地址:https://www.cnblogs.com/feng9exe/p/10343002.html
Copyright © 2020-2023  润新知