Coder Social home page Coder Social logo

jscatswitch's Introduction

images

JSCatSwitch

GitHub license GitHub license CocoaPods Compatible

开始之前

所用到的类: CAGradientLayer;

  • 可以生成两个或者更多颜色平滑渐变.
  • colors : 存放渐变颜色的数组
  • locations: 渐变颜色的区间分布
  • startPoint: 映射locations中的第一个位置,用单位向量表示.
  • endpoint: 映射locations中的最后一个位置,用单位向量表示.
  • type: 默认值是kCAGradientLayerAxial,表示按像素均匀变化。除了默认值也无其它选项。

CAShapeLayer;

  • CALayer 的子类,但比CALayer更灵活,可以画出各种图形.

CAKeyframeAnimation;

  • 关键帧动画,前边博文有详细讲到,在这就不细说了.

开始画画

DrawHelper此类存放画好的path: images

JSCatSwitch此类存放layer属性: images

在点击事件里触发动画:

![images](https://raw.githubusercontent.com/Josin22/JSCatSwitch/master/Source/switch22.png)

在controller里调动: images

主要画画方法讲解

UIBezierPath 里主要方法讲解:

//画二元曲线,一般和moveToPoint配合使用

  • addQuadCurveToPoint:controlPoint;
    //以某个中心点画弧线
  • addArcWithCenter:radius:startAngle:endAngle:clockwise; //以三个点画一段曲线,一般和moveToPoint配合使用
  • addCurveToPoint:controlPoint1:controlPoint2; //根据矩形框的内切圆画曲线
  • bezierPathWithOvalInRect:

最终显示效果

看到这请往右上角点个star吧~谢谢

images

jscatswitch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jscatswitch's Issues

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.