Animation SwiftUI中的键盘和动画问题
我有一个简单的动画Animation SwiftUI中的键盘和动画问题,animation,swiftui,Animation,Swiftui,我有一个简单的动画 Capsule() .cornerRadius(25) .scaleEffect(pulsate ? 1 : 1.2) .animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true).speed(1.5)) .foregroundColor(Color.red) .frame(width: 75, height: 27) .onAppea
Capsule()
.cornerRadius(25)
.scaleEffect(pulsate ? 1 : 1.2)
.animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true).speed(1.5))
.foregroundColor(Color.red)
.frame(width: 75, height: 27)
.onAppear{
self.pulsate.toggle()
}
一切都很好,动画也很好。但是如果我打开一个键盘,当我关闭它时,我的视图胶囊开始跳跃,而不仅仅是做缩放效果。
我真的不知道为什么以及如何解决这个问题
谢谢大家您应该使用
value
制作动画
Capsule()
.cornerRadius(25)
.scaleEffect(pulsate ? 1 : 1.2)
.animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true).speed(1.5))
.foregroundColor(Color.red)
.frame(width: 75, height: 27)
.onAppear{
self.pulsate.toggle()
}
导入快捷界面
结构ContentView:View{
@国有私有var脉动:Bool=Bool()
@状态私有变量stringOfText:String=String()
var body:一些观点{
胶囊()
.转弯半径(25)
.scaleEffect(脉动?1:1.2)
.animation(animation.easeInOut(持续时间:1)。repeatForever(自动反转:true)。速度(1.5),值:脉动)//完美!非常感谢!