gpt4 book ai didi

ios - 拥有 easeIn 动画,然后随着缩放动画永远重复而按顺序缩放动画

转载 作者:行者123 更新时间:2023-12-01 21:25:45 25 4
gpt4 key购买 nike

我想为文本信息和 SF 符号设置一个 easeIn/moveUp 动画 onAppear。此后,我只希望 SF 符号永远按比例放大和缩小。目前,我已经设法永远按比例缩小,但是当我设法链接时,easeIn/moveUp 动画也永远重复自己,它应该只在出现时重复一次。
这是我的应用程序表示的样子:enter image description here
我在下面包含了一段 pin 动画代码:

                HStack (spacing: 20) {
Image(systemName: "pin")
.foregroundColor(.red)
.font(.title2)
.padding(.trailing, 5)
.scaleEffect(animationAmount)
.onAppear {
let baseAnimation = Animation.easeInOut(duration: 1)
let repeated = baseAnimation.repeatForever(autoreverses: true)
return withAnimation(repeated) {
self.animationAmount = 1.5
}
}
VStack (alignment: .leading) {
Text("Pin favourites").fontWeight(.semibold)
Text("You can pin your favourite content on all devices")
.foregroundColor(.gray)
}
Spacer()
}//HStack 2
完整代码在以下页面: SwiftUI - in sheet have a fixed continue button that is not scrollable

最佳答案

您可以加入带有值的动画,如下所示

.scaleEffect(animationAmount)
.animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true), value: animationAmount)
.onAppear {
self.animationAmount = 1.5
}
此外,由于现在动画和状态是唯一连接的并且不会与其他动画/状态冲突,您可以将最后两个修改器移动到最顶部的容器(而不是重复它们三次)
例如这里:
}//VStack for 3 criterias
.padding([.leading, .trailing], 20)
.animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true), value: animationAmount)
.onAppear {
self.animationAmount = 1.5
}

关于ios - 拥有 easeIn 动画,然后随着缩放动画永远重复而按顺序缩放动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63535860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com