SkillAgentSearch skills...

TFAnimation

Enhance CABasicAnimation with custom timingFunction

Install / Use

/learn @luowenxing/TFAnimation
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

TFAnimation

The timingFunction of CAAnimation only allow us create a named or cubic-bezier CAMediaTimingFunction.Now the TFAnimation is a light weight implementation which enhance CABasicAnimation with custom timingFunction whose domain should be between 0 and 1 like cubic-bezier.

Demo

A simple sin curve like animation

A simple sin curve like animation with timingFunction of f(t) = sin (4π * t)

Usage

  • Drag TFAnimation folder to your project
  • Use it just as CABasicAnimation except assign timeFunction with a block (CGFloat) -> CGFloat rather than assign timingFunction
let animationY = TFBasicAnimation()
animationY.keyPath = "position.y"
animationY.fromValue = 0
animationY.byValue = height / 4
animationY.duration = 5.0
animationY.timeFunction = {
  t in 
  return t * t
}
  • There are some pre-defined time function for convience,see TFEasingFunction.swift.

Reference & Inspired

View on GitHub
GitHub Stars12
CategoryDevelopment
Updated3y ago
Forks2

Languages

Swift

Security Score

60/100

Audited on Apr 27, 2022

No findings