Swiftpack.co - brownsoo/ValueAnimator as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by brownsoo.
brownsoo/ValueAnimator 0.6.9
Value transition swift utility
⭐️ 18
🕓 9 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/brownsoo/ValueAnimator.git", from: "0.6.9")


Version License Platform codebeat badge actions workflow

  • ☐ Multiple properties in funcion 'onChanged'


Demo for UIView animation


ValueAnimator makes the transition from initial value to target value using easing functions.

Simple animation

let animator = ValueAnimator.animate("some", from: 0, to: 360, duration: 1.0,
    onChanged: { p, v in 
        print("property \(p): \(v.value)")
    easing: EaseCircular.easeIn())

Yoyo annimation with 2 values

let yoyoAni = ValueAnimator.animate(
    props: ["h", "w"], 
    from: [20, 30], 
    to: [5, 150], 
    duration: 1.4, 
    easing: EaseSine.easeInOut(), 
    onChanged: { p, v in
        if p == "h" {
            let width = self.rect1.bounds.width
            self.rect1.frame = CGRect(x: 24, y: 140, width: width, height:v.cg)
        } else {
            let height = self.rect1.bounds.height
            self.rect1.frame = CGRect(x: 24, y: 140, width:v.cg, height: height)
    option: ValueAnimator.OptionBuilder()


ValueAnimator uses its own work-thread. But the callback changeCallback, endCallback is called in main-thread. if you wanna it called in work-thread, you just set the 'callbackOnMainThread' property is false.

let someView: UIView!
let animator = ValueAnimator.animate("some", from: 0, to: 1, duration: 1.0,
    onChanged: { p, v in 
        // called in ValueAnimator's work-thread
    easing: EaseCircular.easeIn())
animator.callbackOnMainThread = false


To run the example project, clone the repo, and run open ValueAnimator.xcworkspace. You can see ValueAnimatorExample project.


Swift Package Manager

  • Open Xcode
  • Go to File > Swift Packages > Add Package Dependency...
  • Paste this Github Repo URL (https://github.com/brownsoo/ValueAnimator) into the search bar.
  • Select the ValueAnimator repo from the search results.


Simply add the following line to your Podfile:

pod 'ValueAnimator'


brownsoo, @medium


ValueAnimator is available under the MIT license. See the LICENSE file for more info.


Stars: 18
Last commit: 5 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

9 weeks ago
  • changed Minimum iOS to v12
  • fixed "available" property wrapper in xcode 15 (swift 5.9)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics