0
 @IBAction func firstButton(_ sender: UIButton) {
        if textLabel.text == "Cat" {
            textLabel.backgroundColor = .green
            view.backgroundColor = .green
            secondButtonOutlet.isHidden = false
            firstButtonOutlet.isHidden = true
            picker.isHidden = true
            buttonBackOutlet.isHidden = false
        } else {
            secondButtonOutlet.isHidden = true
            countMistakes += 1
            view.backgroundColor = .systemRed
            textLabel.backgroundColor = .systemRed
            UIView.animate(withDuration: 0, delay: 1, options: .allowAnimatedContent, animations: {
                () -> () in
                self.view.backgroundColor = #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1)
                self.textLabel.backgroundColor = #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1)
            }, completion: nil)
        }
    }

I have this code. My goal is to make an animation of red screen blinking. Everything goes well until textLabel. It doesn't want to change its color at all. Can anyone help me how to fix it ? (Background color is changing, so the code should be correct in overall).

SergM1
  • 9
  • 2
  • This might help: https://stackoverflow.com/a/67591642/14351818 – aheze Aug 23 '21 at 17:49
  • @aheze I need a background color of the textLabel to be changed, not the text color – SergM1 Aug 23 '21 at 18:01
  • 1
    very unclear what you're question is asking ... you can set `textLabel.backgroundColor` to fully transparent (`UIColor(white: 1, alpha: 0)`) and just animate `view.backgroundColor` – CSmith Aug 23 '21 at 18:17
  • @CSmith actually that is a solution to my problem. It worked. Thanks! – SergM1 Aug 23 '21 at 20:24

0 Answers0