Given the following struct
:
struct PeopleList : View {
@State var angle: Double = 0.0
@State var isAnimating = true
var foreverAnimatio
UPDATE: There is a backspin involved while stopping the animation which is solved with this solution.
I think its this what you are looking for:
struct PeopleList : View {
@State var angle: Double = 0.0
@State var isAnimating = false
var foreverAnimation: Animation {
Animation.linear(duration: 2.0)
.repeatForever(autoreverses: false)
}
var body: some View {
Button(action: {}, label: {
Image(systemName: "arrow.2.circlepath")
.rotationEffect(Angle(degrees: self.isAnimating ? 360.0 : 0.0))
.animation(self.foreverAnimation)
.onAppear {
self.isAnimating = true
}
})
}
}