Animation.repeatCount() for .offset suggestions

Hey there!

I'm trying to make an animation repeat itself when setting an offset. I want the offset to animate 3 times with autoreverse, but it doesn't seem to have the same effect as with scaleEffect() for example.

My initial thought was:

Code Block
Button(action: {
self.offsetX -= 10
}) {
Text("Tap me")
}
.offset(x: self.offsetX)
.animation(.default)
.repeatCount(3, autoreverse: true)


But it simply doesn't work that way. Any suggestions / thoughts on what could work?

Replies

Your code does not compile. Please show enough code to reproduce your issue.