setBackgroundImage不会更改按钮颜色吗?

时间:2019-03-19 01:01:51

标签: xcode10.1 swift4.2.1

我如何实现setBackgroundImage来短暂更改特定按钮的背景,然后将其恢复为正常状态?

这是我的代码:

@IBAction func answerPressed(_发送者:UIButton){

   if sender.tag == selectedAnswer{

       //Answer is correct so I'd like the button background to briefly turn green

       score += 1

    }
    else {

          //Answer is not correct so the background should turn red


        attempts -= 1

    }

    wordNumber += 1
    updateWord()

} 

0 个答案:

没有答案