- 链式语法
- 无需继承父类
- 轻量级扩展
- 基于UIViewAnimation
- 无代码入侵
- SwiftUI支持
这是一个demo工程并不包含依赖的子模块SwiftSpring, 您需要使用终端或git客户端,例如Source Tree。
终端
git clone --recurse-submodules https://github.com/fanglinwei/SwiftSpring.git从https://github.com/fanglinwei/SwiftSpring.git进行克隆还会将`SwiftSpring`设置为子模块。
CocoaPods - Podfile
pod 'SwiftSpring'Swift Package Manager
您可以使用通过Swift Package Manager在Package.swift文件中添加正确的描述来安装SwiftSpring:
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
targets: [],
dependencies: [
.package(url: "https://github.com/fanglinwei/SwiftSpring-Package.git", from: "0.0.8")
]
)首先导入:
import SwiftSpring下面是一些简单示例. 支持所有设备和模拟器:
animationView.spring
.opacity(0.1)
.scale(0.8, 0.8)
.duration(2)
.curve(.easeOutQuad)
.animate()SwiftUI 支持 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, easeInOutBackforce
duration
delay
damping
velocity
repeatCount
scale
x
y
rotate
alpha* 并非所有属性都能一起使用.
如果你需要实现特定功能或遇到错误,请打开issue。 如果你自己扩展了Spring的功能并希望其他人也使用它,请提交拉取请求。
Spring 使用 MIT 协议. 有关更多信息,请参阅 LICENSE 文件.