- Chained grammar
- No inheritance required
- Lightweight expansion
- Based on UIViewAnimation
- No code intrusion
- SwiftUI support
This is a demo project that does not include the dependency submodule SwiftSpring, you need to use a terminal or git client, such as Source Tree.
Terminal Users
git clone --recurse-submodules https://github.com/fanglinwei/SwiftSpring.gitCloning from https://github.com/fanglinwei/SwiftSpring.git also setups SwiftSpring as submodule.
CocoaPods - Podfile
pod 'SwiftSpring'Swift Package Manager
You can use The Swift Package Manager to install SwiftSpring by adding the proper description to your Package.swift file:
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
targets: [],
dependencies: [
.package(url: "https://github.com/fanglinwei/SwiftSpring-Package.git", from: "0.0.8")
]
)First make sure to import the framework:
import SwiftSpringHere are some usage examples. All devices are also available as simulators:
animationView.spring
.opacity(0.1)
.scale(0.8, 0.8)
.duration(2)
.curve(.easeOutQuad)
.animate()SwiftUI support is available on iOS 13.0+.
@State private var trigger = false
Text("SwiftSpring")
.spring(
.pop,
trigger: trigger,
configuration: SpringConfiguration(duration: 0.7, force: 1)
)animate() { ... }shake
bounce
jump
pop
morph
squeeze
wobble
swing
flipX
flipY
fall
squeezeLeft
squeezeRight
squeezeDown
squeezeUp
slideLeft
slideRight
slideDown
slideUp
fadeIn
fadeOut
fadeInLeft
fadeInRight
fadeInDown
fadeInUp
zoomIn
zoomOut
flashspring
linear
easeIn
easeOut
easeInOut
discrete
easeInSine, easeOutSine, easeInOutSine
easeInQuad, easeOutQuad, easeInOutQuad
easeInCubic, easeOutCubic, easeInOutCubic
easeInQuart, easeOutQuart, easeInOutQuart
easeInQuint, easeOutQuint, easeInOutQuint
easeInExpo, easeOutExpo, easeInOutExpo
easeInCirc, easeOutCirc, easeInOutCirc
easeInBack, easeOutBack, easeInOutBack
force
duration
delay
damping
velocity
repeatCount
scale
x
y
rotate
alpha* Not all properties work together.
If you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue. If you extended the functionality of Spring yourself and want others to use it too, please submit a pull request.
Spring is under MIT license. See the LICENSE file for more info.