I have this code
import UIKit
class ViewController: UIViewController {
@IBAction func touchCard(_ sender: UIButton) {
flipCard(withEmoji: " ", on: sender)
}
func flipCard(withEmoji emoji: String, on button: UIButton) {
if button.currentTitle == emoji {
button.setTitle("", for: UIControlState.normal)
button.backgroundColor = #colorLiteral(red: 1, green: 0.5763723254, blue: 0, alpha: 1)
} else {
button.setTitle(emoji, for: UIControlState.normal)
button.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
}
}
}
The code must flip a card, but it don't work.
However, if I change this line of code and insert a space between the quotes, the code will work.
button.setTitle(" ", for: UIControlState.normal)
What happening? What is wrong? How to fix it?
Link to screenshot and video
https://drive.google.com/open?id=1LPjor519lRf6V-VBSQBMwoov_Q05GLSu
https://drive.google.com/open?id=1Wnm3SCEem2dZLJ9f4JRR_EfbZBDS-_0E