ios - How to prevent an animation from completing when user leaves and returns to app -
i making app have button moving 1 side of screen other. have created pause button pauses animation once button selected. button , function works fine. added function determines if user has exited application. in function, added pause button function. however, when user returns app after exiting, shows pause screen, animation completed. here code: @ibaction func pausebutton(sender: uibutton) { let button = self.view.viewwithtag(1) as? uibutton! let layer = button!.layer pauselayer(layer) // pausing animation view2.hidden = false // showing pause screen } func pauselayer(layer: calayer) { let pausedtime: cftimeinterval = layer.converttime(cacurrentmediatime(), fromlayer: nil) layer.speed = 0.0 layer.timeoffset = pausedtime } @ibaction func startbutton(sender: uibutton) { let button = uibutton() button.tag = 1 // can retrieve in pause function // code make button nice button.translatesautoresizingmaskintoconstraints = false // allow c...