<pre><code>///点击一个 调用3次的 颜色 下拉动画 旋转小图图标
#pragma mark - animation
- (void)animateIndicator:(CAShapeLayer *)indicator Forward:(BOOL)forward complete:(void(^)())complete
{
[CATransaction begin];
[CATransaction setAnimationDuration:0.25];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithControlPoints:0.4 :0.0 :0.2 :1.0]];
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
anim.values = forward ? @[ @0, @(M_PI) ] : @[ @(M_PI), @0 ];
if (!anim.removedOnCompletion) {
[indicator addAnimation:anim forKey:anim.keyPath];
} else {
[indicator addAnimation:anim andValue:anim.values.lastObject forKeyPath:anim.keyPath];
}
[CATransaction commit];
indicator.fillColor = forward ? _tableView.tintColor.CGColor : _menuColor.CGColor;
complete();
}</code></pre>
网友评论