Post

Replies

Boosts

Views

Activity

Reply to How can I deselect a button when other consecutive button is pressed?
let's consider you have named your buttons as follows: 1st button: "opt1Button", 2nd button: "opt2Button", 3rd button: "opt3Button" and so on... create an IBAction with name "optionSelected" The function will look like: @IBAction func optionSelected(_ sender: UIButton) {         opt1Button.isSelected = false opt2Button.isSelected = false         opt3Button.isSelected = false opt4Button.isSelected = false opt5Button.isSelected = false                  sender.isSelected = true     } As soon any of the options is selected all the buttons will go to 'isSelected' false condition i.e all the buttons will be deselected at first and the selected button will be marked as selected. Same process will be followed again when any of the button is selected, everything will get deselected and the button user has pressed will be marked as selected.
Topic: UI Frameworks SubTopic: UIKit Tags:
Feb ’22