In my case, I am trying to creating multiple buttons with single action IBOutlet and tag option. Here, I need to do clicked button selection highlight at a time only one button from multiple buttons. How to achieve this?
My Code
@IBAction private func buttonAction(_ sender: UIButton) {
if let button = sender as? UIButton {
// here I need to do selection highlights at a time only one button from four buttons
}
// To differentiate different buttons
switch (sender.tag) {
case 0:
print(sender.title(for: .normal)!)
case 1:
print(sender.title(for: .normal)!)
case 2:
print(sender.title(for: .normal)!)
case 3:
print(sender.title(for: .normal)!)
default:
print(sender.title(for: .normal)!)
}
}