'animation' 在 iOS 15.0 中被弃用
'animation' was deprecated in iOS 15.0
我使用了一个非常简单的动画,以非常柔和流畅的方式打开按钮栏:
.animation(.spring(response:1.5))
我想将我的应用更新到 iOS15,'animation' 在 iOS 15.0
中已被弃用
所以我尝试将我的动画更改为:
.animation(.spring(response:1.5), value: 0)
或类似的东西:
.animation(.spring(response: 1.5, dampingFraction: 2.5, blendDuration: 2.5), value: 10)
但是新动画弹出的速度很快,流畅的效果没有了
有谁知道如何将我的小 spring 动画带到 iOS 15?
将 animation
修饰符与 value
一起使用时,动画 仅 运行 当 value
改变.
例如,如果在切换布尔值时触发动画,您可以执行以下操作:
@State private var showThing = false
/* ... */
.animation(.spring(response: 1.5), value: showThing)
当运行showThing.toggle()
时,您会看到此动画生效。
animation(_:value:)
的文档:
Applies the given animation to this view when the specified value changes.
A view that applies animation
to this view whenever value
changes.
value
: A value to monitor for changes.
我使用了一个非常简单的动画,以非常柔和流畅的方式打开按钮栏:
.animation(.spring(response:1.5))
我想将我的应用更新到 iOS15,'animation' 在 iOS 15.0
中已被弃用所以我尝试将我的动画更改为:
.animation(.spring(response:1.5), value: 0)
或类似的东西:
.animation(.spring(response: 1.5, dampingFraction: 2.5, blendDuration: 2.5), value: 10)
但是新动画弹出的速度很快,流畅的效果没有了
有谁知道如何将我的小 spring 动画带到 iOS 15?
将 animation
修饰符与 value
一起使用时,动画 仅 运行 当 value
改变.
例如,如果在切换布尔值时触发动画,您可以执行以下操作:
@State private var showThing = false
/* ... */
.animation(.spring(response: 1.5), value: showThing)
当运行showThing.toggle()
时,您会看到此动画生效。
animation(_:value:)
的文档:
Applies the given animation to this view when the specified value changes.
A view that applies
animation
to this view whenevervalue
changes.
value
: A value to monitor for changes.