iOS CAAnimation(四)控制动画过程

本文深入探讨了iOS中Core Animation的动画时间控制,包括如何通过CAAnimation和CALayer的协议来设置精确的动画时机。此外,还介绍了如何使用CATransaction进行动画事务管理,以及如何暂停、恢复动画,以及在事务中隐藏layer动画的效果。
摘要由CSDN通过智能技术生成

Timing is an important part of animations, and with Core Animation you specify precise timing information for your animations through the methods and properties of the CAMediaTiming protocol. Two Core Animation classes adopt this protocol. The CAAnimation class adopts it so that you can specify timing information in your animation objects. The CALayer also adopts it so that you can configure some timing-related features for your implicit animations, although the implicit transaction object that wraps those animations usually provides default timing information that takes precedence.

When thinking about timing and animations, it is important to understand how layer objects work with time. Each layer has its own local time that it uses to manage animation timing. Normally, the local time of two different layers is close enough that you could specify the same time values for each and the user might not notice anything. However, the local time of a layer can be modified by its parent layers or by its own timing parameters. For example, changing the layer’s speed property causes the duration of animations on that layer (and its sublayers) to change proportionally.

时间是动画中很重要的一个概念,我们可以通过CAMediaTiming协议提供的属性来控制动画的时间相关内容。

@interface CAAnimation : NSObject <NSSecureCoding, NSCopying, CAMediaTiming, CAAction>
@interface CALayer : NSObject <NSSecureCoding, CAMediaTiming>

CAAnimation遵守了该协议,我们可以使用该协议指定创建动画中的时间信息。

CALayer也遵守了该协议,隐式动画自动包装了默认时间信息以供使用,我们可以通过这个方式控制隐式动画的时间相关特性。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值