Предполагая, что newGameButton не является частью массива buttons
, вы можете сделать
@IBAction func buttonTapped(_ sender: UIButton) {
if (buttons.contains(sender) {
sender.backgroundColor = UIColor.getrandomColor()
sender.tintColor = UIColor.white
sender.isEnabled = false
}
}
И при запуске новой игры
@IBAction func newGameButton(_ sender: Any) {
//reset all buttons
buttons.forEach { button in
button.backgroundColor = //set default background color
button.tintColor = //set default tint color
button.isEnabled = true
// any other settings
}
}