动画库 CPAnimationSequence

CPAnimationSequence是一款用于声明式地定义包含多个步骤的动画序列的工具。它支持复杂的动画组合,如并行运行步骤及序列,并能实现步骤间的重叠。通过CPAnimationProgram可以进一步控制动画的并行执行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://github.com/yangmeyer/CPAnimationSequence


CPAnimationSequence

Declaratively describe animation sequences that consist of multiple steps.

Something like this:

CPAnimationSequence* shakespeare = [CPAnimationSequence sequenceWithSteps:
    [CPAnimationStep           for:0.2 animate:^{ self.romeo.alpha = 1.0;
                                                       self.julia.alpha = 1.0; }],
    [CPAnimationStep after:1.0 for:0.7 animate:^{
                            CGPoint kiss = CGPointMake((self.romeo.center.x + self.julia.center.x)/2,
                                                       (self.romeo.center.y + self.julia.center.y)/2);
                            self.romeo.center = kiss;
                            self.julia.center = kiss;
    }],
    [CPAnimationStep after:2.0 for:0.5 animate:[self dramaticDeathAnimationStep]],
    [CPAnimationStep           for:0.0 animate:^{ self.theEnd.hidden = NO; }],
    nil];
[shakespeare runAnimated:YES];

I described the rationale and possible improvements on the compeople developer blog on Mobile Apps.

CPAnimationProgram

With the addition of CPAnimationProgram, you can now also run steps (and sequences, and programs) in parallel, or overlap steps (and sequences, and programs).

This is still somewhat experimental, so you might run into problems with particularly complex overlaps. It does seem to work well, though, so give it a try.

Composite pattern

The component implements the Composite design pattern, which means that you can nest sequences and programs as much as device memory and your sanity allow.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值