All I want to do is change the backgroundColor
of fiveMinButton and tenMinButton when fiveMinButton is clicked. Why doesn\'t this code work? @IBAction
You are writing the action method inside the viewDidload, Try this:
override func viewDidLoad() {
super.viewDidLoad()
fiveMinButton.addTarget(self, action: #selector(action(_:)), for: UIControlEvents.touchUpInside)
}
func action(sender: UIButton){
if sender == fiveMinButton {
fiveMinButton.backgroundColor = UIColor.gray
tenMinButton.backgroundColor = UIColor.lightgray
}
}