Cheetah

Easy animation library on iOS with Swift2

  • 所有者: suguru/Cheetah
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Cheetah

Carthage compatible
Pod Version
Swift Version
License MIT
Plaforms

Cheetah is an animation utility on iOS with Swift. Cheetah can animate any properties
since Cheetah uses simple CADisplayLink run loop to change animated properties.

Requirements

  • iOS 8.0~
  • tvOS 9.0~
  • Swift 3.0

Features

  • Animation with duration and delay
  • Changing with absolute/relative properties
  • Parallel/Serial executions
  • Easings
  • Springs

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

To install Cheetah, simply add the following line to your Cartfile:

github "suguru/Cheetah"

Code Example

// Create view
let box = UIView(frame:CGRectMake(100,100,50,50))
box.backgroundColor = UIColor.blueColor()
view.addSubview(box)

// Move to 100px right
box.cheetah.move(100, 0).run()

Simple move

Properties

Cheetah has several methods to animate properties easily. You can also animate your own properties with extending CheetahProperty.

  • move
  • position (absolute of move)
  • scale
  • rotate
  • rotation (absolute of rotate)
  • size
  • frame
  • alpha
  • backgroundColor
  • textColor
  • borderColor
  • borderWidth
  • borderRadius
  • custom properties

Parallel execution

Cheetah groups animation properties and execute them at once.

view.cheetah
  .move(100, 0)
  .rotate(M_PI * 2)
  .scale(1.5)
  .run()

Parallel

Serial execution

wait will wait until all animations placed before it completed.
It can also receive seconds to wait to start next animation.

view.cheetah
  .move(100, 0).rotate(M_PI)
  .wait()
  .move(-100, 0).rotate(-M_PI)
  .wait(1.0) // <- wait 1 sec to start next animation
  .move(0, -20).duration(0.4)
  .wait()
  .move(0, 20).duration(0.4)
  .run()

Serial

Duration and delay

Cheetah has duration and delay to each animation properties.

view.cheetah
  .move(100, 0).duration(1.0).delay(1.0)
  .rotate(M_PI).duration(2.0)
  .wait(1)
  .move(-100, 0).duration(0.4)
  .run()

Delay

Duration will be copied from the property placed before.

view.cheetah
  .duration(0.5)
  .move(100, 0) // <- will have 0.5 sec duration
  .rotate(M_PI) // <- will have 0.5 sec duration
  .run()

Repeating

To repeat animations, use repeatCount(count: Int)

view.cheetah.rotate(M_PI_2).run().repeat(3)

To repeat forever, use forever

view.cheetah.rotate(M_PI_2).run().forever

Repeat

Easings

Cheetah supports various easing functions. You can also add custom easings with quad bezier points.

Easings

Exmaple

view.cheetah.move(150, 150).easeInQuad.run()

Supported eassing equations

  • Linear
  • Sine
  • Quad
  • Quart
  • Quint
  • Circ
  • Cubic
  • Expo
  • Back
  • Bounce
  • Elastic

Springs

Cheetah supports spring dynamics with tension and friction parameters.

Springs

Example

view.cheetah
  .move(200, 0)
  .spring()
  .run()

view.cheetah
  .move(200, 0)
  .spring(tension: 100, friction: 4)
  .run()

Animate custom properties

You can extend CheetahProperty to animate custom properties. You can refer CheetahViewProperties.swift and CheetahLayerProperties.swift.

:)

主要指標

概覽
名稱與所有者suguru/Cheetah
主編程語言Swift
編程語言Swift (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2015-08-21 00:31:23
推送於2018-10-03 13:28:32
最后一次提交2016-10-20 00:13:37
發布數13
最新版本名稱0.4.1 (發布於 2016-10-20 00:08:31)
第一版名稱0.1.0 (發布於 2015-08-22 01:39:55)
用户参与
星數589
關注者數18
派生數47
提交數43
已啟用問題?
問題數11
打開的問題數7
拉請求數2
打開的拉請求數1
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?