vendredi 29 novembre 2019

Compare UIColor to Text Label/String [SWIFT]

How can I test to see if the textColor of a label (meaningLabel) matches the name of the color in another label (textColorLabel)?

ex: (red color appears on screen) == "RED" (appears on label) --> score += 1 (blue color appears on screen) == "BLUE" (appears on label) --> "boo -- no match"

Here is my attempt:

    func updateScore() {
        if meaningLabel.textColor == textColorLabel.textColor{
            print("yay -- match")
            score += 1
            scoreLabel.text = String(score)
        } else {
            print("boo -- no match")
        }
    }

Aucun commentaire:

Enregistrer un commentaire