ios - Start/stop image view rotation animations -
sorry if newbie question, new ios & swift. i have start/stop button , image view want rotate. when press button want start rotating , when press button again image should stop rotating. using uiview animation, haven't figured out way stop view animations. i want image rotate, when animation stops image shouldn't go starting postion, instead continue animation. var istapped = true @ibaction func startstopbuttontapped(_ sender: any) { ruotate() istapped = !istapped } func ruotate() { if istapped { uiview.animate(withduration: 5, delay: 0, options: .repeat, animations: { () -> void in self.imagewood.transform = self.imagewood.transform.rotated(by: cgfloat(m_pi_2)) }, completion: { finished in ruotate() }) } } it code, doesn't work aspect. swift 3.x start animation let rotationanimation : cabasicanimation = cabasicanimation(keypath: "t...