Wie ändere ich die Farbe von Button2, wenn ich auf Button1 klicke?

lles, was ich tun möchte, ist die @ ändebackgroundColor von fiveMinButton und tenMinButton, wenn fiveMinButton angeklickt wird. Warum funktioniert dieser Code nicht?@IBAction wird auch nicht funktionieren.

@IBOutlet weak var fiveMinButton: UIButton!



 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

        }

    }

Antworten auf die Frage(6)

Ihre Antwort auf die Frage