How to stop uiview animate ?

func calis() {
let duration: Double = 0.1
Code Block
UIView.animate(withDuration: duration, delay: 0, options: [.repeat, .autoreverse, .curveEaseIn] , animations: {
self.mm.transform = CGAffineTransform(rotationAngle: .pi)
self.l(view: self.pl)
self.r(view: self.pr)
}) { (_) in
}
}
I see 2 solutions at least:
  • remove all animation for the object

  • declare a new animation with zero duration.

removing all animations will leave the view in the state where it is when animation stops.
So, you have to restore the star you want.

You could also read this
https://stackoverflow.com/questions/13991465/stop-an-auto-reverse-infinite-repeat-uiview-animation-with-a-bool-completion
How to stop uiview animate ?
 
 
Q