我正在尝试在背景中实现带有脉动圆的错误标志。每当我多次单击它时,它都会向内而不是向外跳动。我无法理解这种行为。请建议我正确的方法。
Image(systemName: "exclamationmark")
.background(
ZStack{
Circle()
.fill(Color.red.opacity(0.3))
.frame(width: 20, height: 20)
Circle()
.fill(Color.red.opacity(0.4))
.frame(width: 20, height: 20)
.scaleEffect(carError ? 1.5 : 1)
.onTapGesture(perform: {
carError.toggle()
})
}
.animation(carError ? Animation.easeIn(duration: 0.7).repeatForever() : nil)
)
.font(.footnote)
.foregroundColor(Color("ColorError"))
.position(x: 100, y: 100)
您只需要切换回.default动画而不是nil
.animation(carError ? Animation.easeIn(duration: 0.7).repeatForever() : .default)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句