可链接的动画 -JHChainableAnimations
查看次数:2292
下载次数:299
上传时间:2015-09-16
大小:836 B
动画的问题何在?
CAAnimations 和 UIView 动画都很强大,但想要把多个动画链接在一起却并不容易,特别是当锚点有改变的情况下。
此外,过于复杂的动画不易阅读。
例如,假如我想把 myView 向右跳跃移动 50像素,然后当运动结束时,用向内擦除的方式更改背景色。
旧方法:
[UIView animateWithDuration:1.0
delay:0.0
usingSpringWithDamping:0.8
initialSpringVelocity:1.0
options:0 animations:^{
CGPoint newPosition = self.myView.frame.origin;
newPosition.x += 50;
self.myView.frame.origin = newPosition;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
self.myView.backgroundColor = [UIColor purpleColor];
} completion:nil];
}];
新方法(使用JHChainableAnimations!!!)
self.myView.moveX(50).spring.thenAfter(1.0).makeBackground([UIColor purpleColor]).easeIn.animate(0.5);
收藏