0

I am trying to make a feature where if the user presses the speaker button (a bar button item), then a speaker with a slash through it will replace the original button. Is there an easy way of doing this? I know that it must be done programatically but I can't figure out how to replace the speaker button with a different button.

[Here is a screenshot of my storyboard] : https://i.sstatic.net/EL3df.png

1 Answer 1

1

Add an action for UIBarButtonItem on your UIViewController class by control dragging it into the ViewController's declaration. Then change the item

@IBAction func barButtonAction(_ sender: UIBarButtonItem) {
    sender.image = UIImage(named: "myNewImage")
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.