How do I change the name of button A when button B is pressed?

In Swift, I want to change the title of button A when button B is pressed.

I tried sender.ButtonA.setTitle("Title", forState: UIControlState.Normal)

under IBAction B button but it didn't work. It was just a guess.


source to share

1 answer

You cannot use it sender

for your needs. Because sender

- is the button you clicked on, not the one you want to change the name.

So, you need to make IBOutlet

your buttons look like you by creating your IBAction. Then you can call it like this:

yourButton.setTitle("Title", forState: UIControlState.Normal)




All Articles