VDAnimation
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
- Animate - simple UIKit animation, it's initialized by closure
- SwiftUIAnimate (beta) - simple SwiftUI animation, it's initialized by closure
- Sequential - sequential animations running one after another
- Parallel - parallel animations running simultaneously
- Interval - time interval
- Instant - any block of code, always zero duration
- ForEachFrame
Modifiers
- duration(TimeInterval) - sets the animation duration in seconds
- duration(relative: Double) - sets the animation duration relative to the parent animation in 0...1
- curve(BezierCurve) - sets the animation curve
- spring(dampingRatio: CGFloat = 0.3) - sets spring animation curve (UIViewAnimate)
- ca - UIView, CALayer and View extension to describe an animation of one property
let animation = someView.ca.anyMutableViewProperty.set(newValue)
Installation
Add the following line to your Podfile:
pod 'VDAnimation'
and run pod update
from the podfile directory first.
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.