Created
January 15, 2018 14:17
-
-
Save darhonbek/581db5aaa3f650398311081f41e7f8a1 to your computer and use it in GitHub Desktop.
DevNotes for iOS beginners: Changing button's label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wrong | |
if bgAudioPlayer.isPlaying { | |
bgAudioPlayer.stop() | |
pausePlayButton.titleLabel?.text = "Play" | |
} else { | |
bgAudioPlayer.play() | |
pausePlayButton.titleLabel?.text = "Pause" | |
} | |
// Right | |
if bgAudioPlayer.isPlaying { | |
bgAudioPlayer.stop() | |
pausePlayButton.setTitle("Play", for: .normal) | |
} else { | |
bgAudioPlayer.play() | |
pausePlayButton.setTitle("Pause", for: .normal) | |
} | |
// #ios #devnotes #swift |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment