Using Swift, how do I make a:
Step 1: Create a Bool variable
var isPlaying:Bool = false
Step 2: Connect your button with this IBAction method:
@IBAction func btnStartStop(sender: UIButton) {
if isPlaying{
isPlaying = false
sender.setTitle("Pause", forState: UIControlState.Normal)
sender.setImage(pauseImage, forState: .Normal)
//Pause Stopwatch
}
else{
isPlaying = true
sender.setTitle("Play", forState: UIControlState.Normal)
sender.setImage(playImage, forState: .Normal)
//Play Stopwatch
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With