VDAnimation 0.1.32

VDAnimation 0.1.32

Maintained by dankinsoid.



 
Depends on:
ConstraintsOperators>= 0
VD~> 1.0.51
 

  • By
  • Voidilov

VDAnimation

CI Status Version License Platform

Description

This repository provides a new declarative way to describe animations

Example

Sequential {
  Parallel {
    someView.ca.frame.origin.y.set(100)
    someView.ca.backgroundColor.set(.red).duration(relative: 0.2)
  }
  Parallel {
    someView.ca.transform.set(CGAffineTransform(rotationAngle: CGFloat.pi / 3))
    someView.ca.backgroundColor.set(.white).duration(0.1)
    Sequential {
      someView.ca.backgroundColor.set(.blue)
      someView.ca.backgroundColor.set(.green)
    }
  }
  Animate {
    self.imageHeightConstraint.constant = 50
    self.view.layoutIfNeeded()
  }
  ForEachFrame { progress in
  	someLabel.textColor = (UIColor.white...UIColor.red).at(progress)
  }
}
.curve(.easeInOut)
.duration(3)
.start()

Usage

Basic animations

  1. Animate - simple UIKit animation, it's initialized by closure
  2. SwiftUIAnimate (beta) - simple SwiftUI animation, it's initialized by closure
  3. Sequential - sequential animations running one after another
  4. Parallel - parallel animations running simultaneously
  5. Interval - time interval
  6. Instant - any block of code, always zero duration
  7. ForEachFrame

Modifiers

  1. duration(TimeInterval) - sets the animation duration in seconds
  2. duration(relative: Double) - sets the animation duration relative to the parent animation in 0...1
  3. curve(BezierCurve) - sets the animation curve
  4. spring(dampingRatio: CGFloat = 0.3) - sets spring animation curve (UIViewAnimate)
  5. ca - UIView, CALayer and View extension to describe an animation of one property
	let animation = someView.ca.anyMutableViewProperty.set(newValue)

Installation

  1. CocoaPods

Add the following line to your Podfile:

pod 'VDAnimation'

and run pod update from the podfile directory first.

  1. Swift Package Manager

Create a Package.swift file.

// swift-tools-version:5.0
import PackageDescription

let package = Package(
  name: "SomeProject",
  dependencies: [
    .package(url: "https://github.com/dankinsoid/VDAnimation.git", from: "0.1.3")
  ],
  targets: [
    .target(name: "SomeProject", dependencies: ["VDAnimation"])
  ]
)
$ swift build

Author

dankinsoid, [email protected]

License

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