欢迎同样喜爱动效的你加入
iOS动效特攻队–>QQ群:547897182
iOS动效特攻队–>熊熊:648070256
CRAnimation开源项目:https://github.com/CRAnimation/CRAnimation
原型地址:https://dribbble.com/shots/3504395-App-icon-football
这个还是很简单的,在CAShapeLayer上使用CABasicanimation就能实现这个效果。核心代码直有一小段
- (void)startAnimation
{
CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.79 :0.14 :0.13 :0.83];
CABasicAnimation *animation = [CABasicAnimation animation];
animation.keyPath = @"transform.rotation";
animation.duration = 2.5
;
animation.repeatCount = INFINITY;
animation.byValue = @(M_PI * 2);
animation.timingFunction = timingFunction;
[_ballContentLayer addAnimation:animation forKey:animation.keyPath];
}
要点也只有两个,
animation.repeatCount = INFINITY;
动画循环次数设为INFINITY
,无穷大CAMediaTimingFunction
速度控制函数,用于控制小球的运动速度。 关于这个函数,大家可以看下动画解释里“时间函数”的部分。另外,对于这个函数里四个参数,可以参考在线工具CAMediaTimingFunction playground来理解