keyframeAnimator
视图修饰符(及其变体)。一个概念,旨在更轻松地在 SwiftUI 中定义简单的关键帧/多步骤动画,而无需:
@State
值asyncAfter
该方法经历了几次非常不同的迭代(参见提交历史),但仍有改进的空间。PR 和 讨论 欢迎!
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
// This animation will start as soon as the view appears.
.animate(
.start {
$0.opacity = 0.5
},
.at(2) {
$0.opacity = 1
$0.offsetY = 50
$0.scale = 1.5
}
)
}
}
}
此库在 MIT 许可证下发布。有关更多信息,请参阅 LICENSE 文件。
AnimationViewModifier.swift
)