Code Monkey home page Code Monkey logo

cryoyoballanimation's Introduction

欢迎同样喜爱动效的你加入
iOS动效特攻队–>QQ群:547897182
iOS动效特攻队–>熊熊:648070256
CRAnimation开源项目:https://github.com/CRAnimation/CRAnimation

本来是群里一个小伙伴的原型

原型地址:https://dribbble.com/shots/3504395-App-icon-football

footBall.gif

看着觉得还不错,难度也不大,就决定还原一下了。

下面是最终实现效果,背景的网格线就没有加了

CRYoYoBallAnimation.gif

这个还是很简单的,在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来理解

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.