CPAnimationSequenceiOS视图动画效果
编写iOS视图UIView的动画效果需要很多代码,虽然iOS 4支持块定义,对视图动画的定义减少了不少代码,但语法依旧不好看。CPAnimationSequence是一个开源代码库,可以一种间接快捷的方式来定义描述动画队列,克服了写繁多的代码。
下面一个使用例子:
CPAnimationSequence* shakespeare = [CPAnimationSequence sequenceWithSteps:
[CPAnimationStep for:0.2 animate:^{ self.romeo.alpha = 1.0; }],
[CPAnimationStep for:0.2 animate:^{ self.julia.alpha = 1.0; }],
[CPAnimationStep after:1.0 for:0.7 animate:^{
CGPoint love = CGPointMake((self.romeo.center.x + self.julia.center.x)/2,
(self.romeo.center.y + self.julia.center.y)/2);
self.romeo.center = love;
self.julia.center = love;
}],
[CPAnimationStep after:2.0 for:0.5 animate:^{ self.romeo.alpha = 0.0;
self.julia.alpha = 0.0; }]
nil];
[shakespeare run];
评论