I have an IBOutlet which conatins the timer code and play button linked to it. I want to change the play button to pause button. Play button is present at the bottom which is added on right side of tool bar with flexible space seperators.
Below is the code:
IBOutlet var pauseButton: UIBarButtonItem!
@IBAction func playButton(sender: AnyObject) {
timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: ("counter"), userInfo: nil, repeats: true)
pauseButton.image = UIImage(named: "tick")
}
You could try using:
@IBAction func pauseButton(sender: AnyObject) {
timer.invalidate()
pauseButton.image = UIImage(named: "tick")
}
Make sure you connect the button to this action. Note that this is not an outlet connection but an action.